aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-01-16 17:26:14 +0800
committerMission Liao <mission.liao@dexon.org>2019-01-28 16:19:51 +0800
commit4cf4acd6b4cb8b61b555d27fae24a5b3d468c09f (patch)
tree000b266d0b6b1004d3939df9d8dfa83658db9048
parent70570f7d7c876762edc0e0fee611a0aa94b15ea1 (diff)
downloaddexon-consensus-4cf4acd6b4cb8b61b555d27fae24a5b3d468c09f.tar.gz
dexon-consensus-4cf4acd6b4cb8b61b555d27fae24a5b3d468c09f.tar.zst
dexon-consensus-4cf4acd6b4cb8b61b555d27fae24a5b3d468c09f.zip
Update lock round/value in processSignal method only
-rw-r--r--core/agreement-state.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/core/agreement-state.go b/core/agreement-state.go
index 73d7b7a..3579fbf 100644
--- a/core/agreement-state.go
+++ b/core/agreement-state.go
@@ -152,16 +152,13 @@ func newCommitState(a *agreementData) *commitState {
func (s *commitState) state() agreementStateType { return stateCommit }
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.lock.RLock()
+ defer s.a.lock.RUnlock()
+ hash := types.SkipBlockHash
+ // Once we received 2t+1 PreCom votes at current period, we should be
+ // able to receive that signal and update locked value/period.
+ if s.a.lockRound == s.a.period {
+ hash = s.a.lockValue
}
s.a.recv.ProposeVote(types.NewVote(types.VoteCom, hash, s.a.period))
return newForwardState(s.a), nil