aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement-state.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-27 15:02:27 +0800
committerJimmy Hu <jimmy.hu@dexon.org>2019-03-27 15:25:10 +0800
commitf848ee5128563138b1757034ea7d387c77679728 (patch)
treece9083e8ae66ea7234d36241a3b1cf8b65fca2a8 /core/agreement-state.go
parent495b3737414685d609f7b41355928c699189d6ad (diff)
downloaddexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.gz
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.bz2
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.lz
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.xz
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.tar.zst
dexon-consensus-f848ee5128563138b1757034ea7d387c77679728.zip
core: Update BA to the latest version (#519)
* core: fastPreCom should not propose fastCom in RBA * add test for fix * core: update BA * core: fix test
Diffstat (limited to 'core/agreement-state.go')
-rw-r--r--core/agreement-state.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/core/agreement-state.go b/core/agreement-state.go
index 73d7b7a..0d1ae58 100644
--- a/core/agreement-state.go
+++ b/core/agreement-state.go
@@ -132,11 +132,14 @@ func (s *preCommitState) clocks() int { return 2 }
func (s *preCommitState) nextState() (agreementState, error) {
s.a.lock.RLock()
defer s.a.lock.RUnlock()
- hash := s.a.lockValue
- if hash == types.NullBlockHash {
- hash = s.a.leader.leaderBlockHash()
+ if s.a.lockValue == types.SkipBlockHash ||
+ s.a.lockValue == types.NullBlockHash {
+ hash := s.a.leader.leaderBlockHash()
+ s.a.recv.ProposeVote(types.NewVote(types.VotePreCom, hash, s.a.period))
+ } else {
+ s.a.recv.ProposeVote(types.NewVote(
+ types.VotePreCom, s.a.lockValue, s.a.period))
}
- s.a.recv.ProposeVote(types.NewVote(types.VotePreCom, hash, s.a.period))
return newCommitState(s.a), nil
}
@@ -154,16 +157,7 @@ func (s *commitState) clocks() int { return 2 }
func (s *commitState) nextState() (agreementState, error) {
s.a.lock.Lock()
defer s.a.lock.Unlock()
- hash, ok := s.a.countVoteNoLock(s.a.period, types.VotePreCom)
- if ok && hash != types.SkipBlockHash {
- if s.a.period > s.a.lockIter {
- s.a.lockValue = hash
- s.a.lockIter = s.a.period
- }
- } else {
- hash = types.SkipBlockHash
- }
- s.a.recv.ProposeVote(types.NewVote(types.VoteCom, hash, s.a.period))
+ s.a.recv.ProposeVote(types.NewVote(types.VoteCom, s.a.lockValue, s.a.period))
return newForwardState(s.a), nil
}