diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-10 18:01:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 18:01:10 +0800 |
commit | fa25817354d5b7d40f5911004232392acfe7fe53 (patch) | |
tree | 6e9c68971d4e5fecbd126568ebdb7f1026935d93 /core/agreement-mgr.go | |
parent | 995e571375298923bf07d205237a664b03de3b57 (diff) | |
download | tangerine-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.gz tangerine-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.tar.zst tangerine-consensus-fa25817354d5b7d40f5911004232392acfe7fe53.zip |
core: fix issues in consensus core (#415)
Diffstat (limited to 'core/agreement-mgr.go')
-rw-r--r-- | core/agreement-mgr.go | 11 |
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, } |