diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-09-13 17:30:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 17:30:42 +0800 |
commit | ce3e7931016bb5f3a68e1b27e308bb54522b34a4 (patch) | |
tree | 56ff2ec31a1c8dfcdad80772815de75438f29a79 /core/agreement-state.go | |
parent | 41f4c2fd789d6b58ca076e675b2ce931aaedb37b (diff) | |
download | dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar.gz dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar.bz2 dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar.lz dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar.xz dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.tar.zst dexon-consensus-ce3e7931016bb5f3a68e1b27e308bb54522b34a4.zip |
core: Fix BA Fork issues (#104)
Diffstat (limited to 'core/agreement-state.go')
-rw-r--r-- | core/agreement-state.go | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/core/agreement-state.go b/core/agreement-state.go index b948417..d7225d6 100644 --- a/core/agreement-state.go +++ b/core/agreement-state.go @@ -69,19 +69,14 @@ func (s *prepareState) nextState() (agreementState, error) { hash := common.Hash{} if s.a.period == 1 { hash = s.a.blockProposer().Hash + s.a.recv.ProposeBlock(hash) } else { var proposed bool - hash, proposed = s.a.countVote(s.a.period-1, types.VotePass) + _, proposed = s.a.countVote(s.a.period-1, types.VotePass) if !proposed { return nil, ErrNoEnoughVoteInPrepareState } - if hash == nullBlockHash { - hash = s.a.blocks[s.a.ID].Hash - } else { - delete(s.a.blocks, s.a.ID) - } } - s.a.recv.ProposeBlock(hash) return newAckState(s.a), nil } func (s *prepareState) receiveVote() error { return nil } @@ -259,30 +254,9 @@ func (s *pass2State) receiveVote() error { if s.voted { return nil } - ackHash, ok := s.a.countVote(s.a.period, types.VoteAck) - if ok && ackHash != nullBlockHash { - s.a.recv.ProposeVote(&types.Vote{ - Type: types.VotePass, - BlockHash: ackHash, - Period: s.a.period, - }) - s.voted = true - } else if s.a.period > 1 { - if _, exist := - s.a.votes[s.a.period][types.VoteConfirm][s.a.ID]; !exist { - hash, ok := s.a.countVote(s.a.period-1, types.VotePass) - if ok && hash == nullBlockHash { - s.a.recv.ProposeVote(&types.Vote{ - Type: types.VotePass, - BlockHash: hash, - Period: s.a.period, - }) - s.voted = true - } - } - } hash, ok := s.a.countVote(s.a.period, types.VotePass) if ok { + s.voted = true s.enoughPassVote <- hash } return nil |