diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-21 13:11:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-21 13:11:04 +0800 |
commit | caa9ad362b4d57bba8551be4074c86f820b7881c (patch) | |
tree | 6c26d273004ecda769c86ced3aacd420c8bd0490 /core/agreement-state.go | |
parent | b27f9c8dce7d0e09ae191dcb00562abf97faa806 (diff) | |
download | dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar.gz dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar.bz2 dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar.lz dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar.xz dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.tar.zst dexon-consensus-caa9ad362b4d57bba8551be4074c86f820b7881c.zip |
core: Fix BA3.0 implmenetation (#426)
* types: Add vote type
* core: remove stateFastRollback
* core: rename lockRound to lockIter
* core: Implement real ba3.0
* core: Add test for confirm
* Fix VoteFastCom in agreement result
* lockIter will always increase
Diffstat (limited to 'core/agreement-state.go')
-rw-r--r-- | core/agreement-state.go | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/core/agreement-state.go b/core/agreement-state.go index 266e442..5b2ce52 100644 --- a/core/agreement-state.go +++ b/core/agreement-state.go @@ -37,7 +37,6 @@ type agreementStateType int const ( stateFast agreementStateType = iota stateFastVote - stateFastRollback stateInitial statePreCommit stateCommit @@ -98,23 +97,8 @@ func newFastVoteState(a *agreementData) *fastVoteState { } func (s *fastVoteState) state() agreementStateType { return stateFastVote } -func (s *fastVoteState) clocks() int { return 2 } +func (s *fastVoteState) clocks() int { return 3 } func (s *fastVoteState) nextState() (agreementState, error) { - return newFastRollbackState(s.a), nil -} - -//----- FastRollbackState ----- -type fastRollbackState struct { - a *agreementData -} - -func newFastRollbackState(a *agreementData) *fastRollbackState { - return &fastRollbackState{a: a} -} - -func (s *fastRollbackState) state() agreementStateType { return stateFastRollback } -func (s *fastRollbackState) clocks() int { return 1 } -func (s *fastRollbackState) nextState() (agreementState, error) { return newInitialState(s.a), nil } @@ -182,8 +166,10 @@ func (s *commitState) nextState() (agreementState, error) { defer s.a.lock.Unlock() hash, ok := s.a.countVoteNoLock(s.a.period, types.VotePreCom) if ok && hash != skipBlockHash { - s.a.lockValue = hash - s.a.lockRound = s.a.period + if s.a.period > s.a.lockIter { + s.a.lockValue = hash + s.a.lockIter = s.a.period + } } else { hash = skipBlockHash } |