|
|
@ -34,6 +34,56 @@ func voteToStep(vote *Vote) int8 { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
// PrivValidator is being upgraded! See types/priv_validator
|
|
|
|
|
|
|
|
// ValidatorID contains the identity of the validator.
|
|
|
|
type ValidatorID struct { |
|
|
|
Address cmn.HexBytes `json:"address"` |
|
|
|
PubKey crypto.PubKey `json:"pub_key"` |
|
|
|
} |
|
|
|
|
|
|
|
// PrivValidator defines the functionality of a local Tendermint validator
|
|
|
|
// that signs votes, proposals, and heartbeats, and never double signs.
|
|
|
|
type PrivValidator2 interface { |
|
|
|
Address() Address // redundant since .PubKey().Address()
|
|
|
|
PubKey() crypto.PubKey |
|
|
|
|
|
|
|
SignVote(chainID string, vote *Vote) error |
|
|
|
SignProposal(chainID string, proposal *Proposal) error |
|
|
|
SignHeartbeat(chainID string, heartbeat *Heartbeat) error |
|
|
|
} |
|
|
|
|
|
|
|
type TestSigner interface { |
|
|
|
Address() cmn.HexBytes |
|
|
|
PubKey() crypto.PubKey |
|
|
|
Sign([]byte) (crypto.Signature, error) |
|
|
|
} |
|
|
|
|
|
|
|
func GenSigner() TestSigner { |
|
|
|
return &DefaultTestSigner{ |
|
|
|
crypto.GenPrivKeyEd25519().Wrap(), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
type DefaultTestSigner struct { |
|
|
|
crypto.PrivKey |
|
|
|
} |
|
|
|
|
|
|
|
func (ds *DefaultTestSigner) Address() cmn.HexBytes { |
|
|
|
return ds.PubKey().Address() |
|
|
|
} |
|
|
|
|
|
|
|
func (ds *DefaultTestSigner) PubKey() crypto.PubKey { |
|
|
|
return ds.PrivKey.PubKey() |
|
|
|
} |
|
|
|
|
|
|
|
func (ds *DefaultTestSigner) Sign(msg []byte) (crypto.Signature, error) { |
|
|
|
return ds.PrivKey.Sign(msg), nil |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
|
|
|
|
// PrivValidator defines the functionality of a local Tendermint validator
|
|
|
|
// that signs votes, proposals, and heartbeats, and never double signs.
|
|
|
|
type PrivValidator interface { |
|
|
@ -379,7 +429,7 @@ func checkVotesOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (time.T |
|
|
|
panic(fmt.Sprintf("signBytes cannot be unmarshalled into vote: %v", err)) |
|
|
|
} |
|
|
|
|
|
|
|
lastTime, err := time.Parse(timeFormat, lastVote.Vote.Timestamp) |
|
|
|
lastTime, err := time.Parse(TimeFormat, lastVote.Vote.Timestamp) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
@ -405,7 +455,7 @@ func checkProposalsOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (ti |
|
|
|
panic(fmt.Sprintf("signBytes cannot be unmarshalled into proposal: %v", err)) |
|
|
|
} |
|
|
|
|
|
|
|
lastTime, err := time.Parse(timeFormat, lastProposal.Proposal.Timestamp) |
|
|
|
lastTime, err := time.Parse(TimeFormat, lastProposal.Proposal.Timestamp) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|