From c8cc33091b0949ba2d413f4aa12ce54212b86547 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Mon, 18 Mar 2019 18:43:57 +0800 Subject: core/syncer: fix a bug in ForceSync (#499) --- core/syncer/consensus.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'core') 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 } -- cgit v1.2.3