diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-07 17:21:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-07 17:21:08 +0800 |
commit | 21c420db895b1aa48709982cd145a119c74de6fa (patch) | |
tree | a8cd9a9bc5e8c22a21812f0e00939f3fbd92db89 /core/utils.go | |
parent | 8d1069b61d847662d37f504937a346c56d6cb0eb (diff) | |
download | dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar.gz dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar.bz2 dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar.lz dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar.xz dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.tar.zst dexon-consensus-21c420db895b1aa48709982cd145a119c74de6fa.zip |
core: BA 3.0 (#408)
* Add v3 enum
* Add BA leader calculation
* Fast BA
* Add unittest for Fast BA
* Add comment
* Select leader in notarySet
Diffstat (limited to 'core/utils.go')
-rw-r--r-- | core/utils.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/utils.go b/core/utils.go index 0c2d155..3b1069e 100644 --- a/core/utils.go +++ b/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 } |