diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-12-12 16:55:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 16:55:19 +0800 |
commit | 338bf8676563a103cc78bbacef75fbaaac4293d7 (patch) | |
tree | 33587f90c7d7b8d61c99bebeb4ffee9c0b69668f /core/agreement-mgr.go | |
parent | d60fedadb35d56ed873bad301cf3e5fd9a96410d (diff) | |
download | tangerine-consensus-338bf8676563a103cc78bbacef75fbaaac4293d7.tar.gz tangerine-consensus-338bf8676563a103cc78bbacef75fbaaac4293d7.tar.zst tangerine-consensus-338bf8676563a103cc78bbacef75fbaaac4293d7.zip |
syncer: fix stuffs (#366)
* return delivered blocks when processing finalized blocks
* check deliver sequence when processing finalized blocks
* skip delivery of finalized blocks
* remove duplicated calls to BlockConfirmed
* add numChains change in test scenario
* fix the bug that restartNotary is triggered by older block
than current aID.
Diffstat (limited to 'core/agreement-mgr.go')
-rw-r--r-- | core/agreement-mgr.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go index c95f913..4cb47b1 100644 --- a/core/agreement-mgr.go +++ b/core/agreement-mgr.go @@ -20,6 +20,7 @@ package core import ( "context" "errors" + "math" "sync" "time" @@ -174,7 +175,7 @@ func (mgr *agreementMgr) appendConfig( recv := &consensusBAReceiver{ consensus: mgr.con, chainID: i, - restartNotary: make(chan bool, 1), + restartNotary: make(chan types.Position, 1), } agrModule := newAgreement( mgr.con.ID, @@ -252,7 +253,9 @@ func (mgr *agreementMgr) processAgreementResult( int(mgr.gov.Configuration(result.Position.Round).NotarySetSize), types.NewNotarySetTarget(crs, result.Position.ChainID)) for key := range result.Votes { - agreement.processVote(&result.Votes[key]) + if err := agreement.processVote(&result.Votes[key]); err != nil { + return err + } } agreement.restart(nIDs, result.Position, crs) } @@ -388,7 +391,7 @@ Loop: // Run BA for this round. recv.round = currentRound recv.changeNotaryTime = roundEndTime - recv.restartNotary <- false + recv.restartNotary <- types.Position{ChainID: math.MaxUint32} if err := mgr.baRoutineForOneRound(&setting); err != nil { mgr.logger.Error("BA routine failed", "error", err, @@ -412,10 +415,17 @@ Loop: default: } select { - case newNotary := <-recv.restartNotary: - if newNotary { - // This round is finished. - break Loop + case restartPos := <-recv.restartNotary: + if !isStop(restartPos) { + if restartPos.Round > oldPos.Round { + // This round is finished. + break Loop + } + if restartPos.Older(&oldPos) { + // The restartNotary event is triggered by 'BlockConfirmed' + // of some older block. + break + } } var nextHeight uint64 for { |