aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement-mgr.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-10 18:01:10 +0800
committerGitHub <noreply@github.com>2019-01-10 18:01:10 +0800
commitfa25817354d5b7d40f5911004232392acfe7fe53 (patch)
tree6e9c68971d4e5fecbd126568ebdb7f1026935d93 /core/agreement-mgr.go
parent995e571375298923bf07d205237a664b03de3b57 (diff)
downloaddexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.gz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.bz2
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.lz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.xz
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.zst
dexon-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.zip
core: fix issues in consensus core (#415)
Diffstat (limited to 'core/agreement-mgr.go')
-rw-r--r--core/agreement-mgr.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go
index a995cca..eb4abda 100644
--- a/core/agreement-mgr.go
+++ b/core/agreement-mgr.go
@@ -22,6 +22,7 @@ import (
"errors"
"math"
"sync"
+ "sync/atomic"
"time"
"github.com/dexon-foundation/dexon-consensus/common"
@@ -180,7 +181,9 @@ func (mgr *agreementMgr) appendConfig(
consensus: mgr.con,
chainID: i,
restartNotary: make(chan types.Position, 1),
+ roundValue: &atomic.Value{},
}
+ recv.roundValue.Store(uint64(0))
agrModule := newAgreement(
mgr.con.ID,
recv,
@@ -399,7 +402,7 @@ Loop:
<-setting.ticker.Tick()
}
// Run BA for this round.
- recv.round = currentRound
+ recv.roundValue.Store(currentRound)
recv.changeNotaryTime = roundEndTime
recv.restartNotary <- types.Position{ChainID: math.MaxUint32}
if err := mgr.baRoutineForOneRound(&setting); err != nil {
@@ -439,11 +442,11 @@ Loop:
}
var nextHeight uint64
for {
- nextHeight, err = mgr.lattice.NextHeight(recv.round, setting.chainID)
+ nextHeight, err = mgr.lattice.NextHeight(recv.round(), setting.chainID)
if err != nil {
mgr.logger.Debug("Error getting next height",
"error", err,
- "round", recv.round,
+ "round", recv.round(),
"chainID", setting.chainID)
err = nil
nextHeight = oldPos.Height
@@ -459,7 +462,7 @@ Loop:
time.Sleep(100 * time.Millisecond)
}
nextPos := types.Position{
- Round: recv.round,
+ Round: recv.round(),
ChainID: setting.chainID,
Height: nextHeight,
}