mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 19:53:58 +00:00
@@ -17,13 +17,13 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrVoteUnexpectedStep = errors.New("Unexpected step")
|
||||
ErrVoteInvalidValidatorIndex = errors.New("Invalid validator index")
|
||||
ErrVoteInvalidValidatorAddress = errors.New("Invalid validator address")
|
||||
ErrVoteInvalidSignature = errors.New("Invalid signature")
|
||||
ErrVoteInvalidBlockHash = errors.New("Invalid block hash")
|
||||
ErrVoteNonDeterministicSignature = errors.New("Non-deterministic signature")
|
||||
ErrVoteNil = errors.New("Nil vote")
|
||||
ErrVoteUnexpectedStep = errors.New("unexpected step")
|
||||
ErrVoteInvalidValidatorIndex = errors.New("invalid validator index")
|
||||
ErrVoteInvalidValidatorAddress = errors.New("invalid validator address")
|
||||
ErrVoteInvalidSignature = errors.New("invalid signature")
|
||||
ErrVoteInvalidBlockHash = errors.New("invalid block hash")
|
||||
ErrVoteNonDeterministicSignature = errors.New("non-deterministic signature")
|
||||
ErrVoteNil = errors.New("nil vote")
|
||||
)
|
||||
|
||||
type ErrVoteConflictingVotes struct {
|
||||
@@ -124,39 +124,39 @@ func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error {
|
||||
// ValidateBasic performs basic validation.
|
||||
func (vote *Vote) ValidateBasic() error {
|
||||
if !IsVoteTypeValid(vote.Type) {
|
||||
return errors.New("Invalid Type")
|
||||
return errors.New("invalid Type")
|
||||
}
|
||||
if vote.Height < 0 {
|
||||
return errors.New("Negative Height")
|
||||
return errors.New("negative Height")
|
||||
}
|
||||
if vote.Round < 0 {
|
||||
return errors.New("Negative Round")
|
||||
return errors.New("negative Round")
|
||||
}
|
||||
|
||||
// NOTE: Timestamp validation is subtle and handled elsewhere.
|
||||
|
||||
if err := vote.BlockID.ValidateBasic(); err != nil {
|
||||
return fmt.Errorf("Wrong BlockID: %v", err)
|
||||
return fmt.Errorf("wrong BlockID: %v", err)
|
||||
}
|
||||
// BlockID.ValidateBasic would not err if we for instance have an empty hash but a
|
||||
// non-empty PartsSetHeader:
|
||||
if !vote.BlockID.IsZero() && !vote.BlockID.IsComplete() {
|
||||
return fmt.Errorf("BlockID must be either empty or complete, got: %v", vote.BlockID)
|
||||
return fmt.Errorf("blockID must be either empty or complete, got: %v", vote.BlockID)
|
||||
}
|
||||
if len(vote.ValidatorAddress) != crypto.AddressSize {
|
||||
return fmt.Errorf("Expected ValidatorAddress size to be %d bytes, got %d bytes",
|
||||
return fmt.Errorf("expected ValidatorAddress size to be %d bytes, got %d bytes",
|
||||
crypto.AddressSize,
|
||||
len(vote.ValidatorAddress),
|
||||
)
|
||||
}
|
||||
if vote.ValidatorIndex < 0 {
|
||||
return errors.New("Negative ValidatorIndex")
|
||||
return errors.New("negative ValidatorIndex")
|
||||
}
|
||||
if len(vote.Signature) == 0 {
|
||||
return errors.New("Signature is missing")
|
||||
return errors.New("signature is missing")
|
||||
}
|
||||
if len(vote.Signature) > MaxSignatureSize {
|
||||
return fmt.Errorf("Signature is too big (max: %d)", MaxSignatureSize)
|
||||
return fmt.Errorf("signature is too big (max: %d)", MaxSignatureSize)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user