aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-11-05 11:44:49 +0800
committerGitHub <noreply@github.com>2018-11-05 11:44:49 +0800
commit900643e2ac8c953d10fd3f8f56b9d49ad5b825f6 (patch)
treec02ae2606e19021894e1035162ddd33c971c063a /core/agreement.go
parent740c5775e4fe97eaacd8c8bfe8f39076018565ab (diff)
downloaddexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar.gz
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar.bz2
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar.lz
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar.xz
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.tar.zst
dexon-consensus-900643e2ac8c953d10fd3f8f56b9d49ad5b825f6.zip
core: New BA (#295)
Diffstat (limited to 'core/agreement.go')
-rw-r--r--core/agreement.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/agreement.go b/core/agreement.go
index 80c0e2c..f31b7ef 100644
--- a/core/agreement.go
+++ b/core/agreement.go
@@ -160,7 +160,7 @@ func (a *agreement) restart(
a.data.requiredVote = len(notarySet)/3*2 + 1
a.data.leader.restart(crs)
a.data.lockValue = nullBlockHash
- a.data.lockRound = 1
+ a.data.lockRound = 0
a.fastForward = make(chan uint64, 1)
a.hasOutput = false
a.state = newInitialState(a.data)
@@ -237,7 +237,10 @@ func (a *agreement) clocks() int {
// pullVotes returns if current agreement requires more votes to continue.
func (a *agreement) pullVotes() bool {
- return a.state.state() == statePullVote
+ a.data.lock.RLock()
+ defer a.data.lock.RUnlock()
+ return a.state.state() == statePullVote ||
+ (a.state.state() == statePreCommit && (a.data.period%3) == 0)
}
// agreementID returns the current agreementID.
@@ -345,7 +348,6 @@ func (a *agreement) processVote(vote *types.Vote) error {
vote.BlockHash != a.data.lockValue {
a.data.lockValue = hash
a.data.lockRound = vote.Period
- a.fastForward <- a.data.period + 1
return nil
}
// Condition 2.