diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-01-17 11:00:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 11:00:42 +0800 |
commit | c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3 (patch) | |
tree | 526b0805f0bef525007664cf712b165d42ff9f0b | |
parent | 48bf5a8d270fcac87aefb9366f29383b85745407 (diff) | |
download | dexon-consensus-c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3.tar.gz dexon-consensus-c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3.tar.zst dexon-consensus-c5b303f4d143631fb565d4ec8ff3bcc609a4ffd3.zip |
core: Fix syncing BA issues (#421)
-rw-r--r-- | core/agreement-mgr.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go index e468e9c..d3cf533 100644 --- a/core/agreement-mgr.go +++ b/core/agreement-mgr.go @@ -258,13 +258,20 @@ func (mgr *agreementMgr) processAgreementResult( if isStop(aID) { return nil } - if result.Position.Newer(&aID) { + if result.Position == aID { mgr.logger.Info("Syncing BA", "position", &result.Position) + for key := range result.Votes { + if err := agreement.processVote(&result.Votes[key]); err != nil { + return err + } + } + } else if result.Position.Newer(&aID) { + mgr.logger.Info("Fast syncing BA", "position", &result.Position) nodes, err := mgr.cache.GetNodeSet(result.Position.Round) if err != nil { return err } - mgr.logger.Debug("Calling Network.PullBlocks for syncing BA", + mgr.logger.Debug("Calling Network.PullBlocks for fast syncing BA", "hash", result.BlockHash) mgr.network.PullBlocks(common.Hashes{result.BlockHash}) mgr.logger.Debug("Calling Governance.CRS", "round", result.Position.Round) @@ -459,16 +466,16 @@ Loop: "round", recv.round(), "chainID", setting.chainID) err = nil - nextHeight = oldPos.Height + nextHeight = restartPos.Height } - if isStop(oldPos) || nextHeight == 0 { + if isStop(restartPos) || nextHeight == 0 { break } - if nextHeight > oldPos.Height { + if nextHeight > restartPos.Height { break } mgr.logger.Debug("Lattice not ready!!!", - "old", &oldPos, "next", nextHeight) + "old", &restartPos, "next", nextHeight) time.Sleep(100 * time.Millisecond) } nextPos := types.Position{ |