diff options
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go index 3b1069eb8..14780e73b 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go @@ -32,6 +32,20 @@ import ( "github.com/dexon-foundation/dexon-consensus/core/utils" ) +// Errors for utils. +var ( + ErrIncorrectVoteBlockHash = fmt.Errorf( + "incorrect vote block hash") + ErrIncorrectVoteType = fmt.Errorf( + "incorrect vote type") + ErrIncorrectVotePosition = fmt.Errorf( + "incorrect vote position") + ErrIncorrectVoteProposer = fmt.Errorf( + "incorrect vote proposer") + ErrIncorrectVotePeriod = fmt.Errorf( + "incorrect vote period") +) + // NodeSetCache is type alias to avoid fullnode compile error when moving // it to core/utils package. type NodeSetCache = utils.NodeSetCache @@ -161,10 +175,14 @@ func VerifyAgreementResult( } voted := make(map[types.NodeID]struct{}, len(notarySet)) voteType := res.Votes[0].Type - if voteType != types.VoteFast && voteType != types.VoteCom { + votePeriod := res.Votes[0].Period + if voteType != types.VoteFastCom && voteType != types.VoteCom { return ErrIncorrectVoteType } for _, vote := range res.Votes { + if vote.Period != votePeriod { + return ErrIncorrectVotePeriod + } if res.IsEmptyBlock { if (vote.BlockHash != common.Hash{}) { return ErrIncorrectVoteBlockHash |