aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
diff options
context:
space:
mode:
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.go12
1 files changed, 9 insertions, 3 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 0c2d15588..3b1069eb8 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils.go
@@ -159,8 +159,10 @@ func VerifyAgreementResult(
if len(res.Votes) < len(notarySet)/3*2+1 {
return ErrNotEnoughVotes
}
- if len(res.Votes) > len(notarySet) {
- return ErrIncorrectVoteProposer
+ voted := make(map[types.NodeID]struct{}, len(notarySet))
+ voteType := res.Votes[0].Type
+ if voteType != types.VoteFast && voteType != types.VoteCom {
+ return ErrIncorrectVoteType
}
for _, vote := range res.Votes {
if res.IsEmptyBlock {
@@ -172,7 +174,7 @@ func VerifyAgreementResult(
return ErrIncorrectVoteBlockHash
}
}
- if vote.Type != types.VoteCom {
+ if vote.Type != voteType {
return ErrIncorrectVoteType
}
if vote.Position != res.Position {
@@ -188,6 +190,10 @@ func VerifyAgreementResult(
if !ok {
return ErrIncorrectVoteSignature
}
+ voted[vote.ProposerID] = struct{}{}
+ }
+ if len(voted) < len(notarySet)/3*2+1 {
+ return ErrNotEnoughVotes
}
return nil
}