aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-03-18 18:43:57 +0800
committerGitHub <noreply@github.com>2019-03-18 18:43:57 +0800
commitc8cc33091b0949ba2d413f4aa12ce54212b86547 (patch)
tree1e737751dc0641ea4bf1016c318d110b19b972d0
parent8218cb1525872cc0c7f09335305bcbed484153ad (diff)
downloaddexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar.gz
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar.bz2
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar.lz
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar.xz
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.tar.zst
dexon-consensus-c8cc33091b0949ba2d413f4aa12ce54212b86547.zip
core/syncer: fix a bug in ForceSync (#499)
-rw-r--r--core/syncer/consensus.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/syncer/consensus.go b/core/syncer/consensus.go
index f2f8f9e..8d89d07 100644
--- a/core/syncer/consensus.go
+++ b/core/syncer/consensus.go
@@ -263,11 +263,14 @@ func (con *Consensus) ForceSync(skip bool) {
con.setupConfigsUntilRound(block.Position.Round + core.ConfigRoundShift - 1)
con.syncedLastBlock = &block
con.stopBuffering()
- con.dummyCancel, con.dummyFinished = utils.LaunchDummyReceiver(
- context.Background(), con.network.ReceiveChan(),
- func(msg interface{}) {
- con.dummyMsgBuffer = append(con.dummyMsgBuffer, msg)
- })
+ // We might call stopBuffering without calling assureBuffering.
+ if con.dummyCancel == nil {
+ con.dummyCancel, con.dummyFinished = utils.LaunchDummyReceiver(
+ context.Background(), con.network.ReceiveChan(),
+ func(msg interface{}) {
+ con.dummyMsgBuffer = append(con.dummyMsgBuffer, msg)
+ })
+ }
con.syncedSkipNext = skip
}