diff --git a/blockchain/v0/reactor.go b/blockchain/v0/reactor.go index 2889fe0f6..dc30afd96 100644 --- a/blockchain/v0/reactor.go +++ b/blockchain/v0/reactor.go @@ -41,6 +41,7 @@ type consensusReactor interface { // for when we switch from blockchain reactor and fast sync to // the consensus machine SwitchToConsensus(sm.State, int) + SwitchToCatchUp() } type hotsyncReactor interface { @@ -303,6 +304,10 @@ FOR_LOOP: hotR, ok := bcR.Switch.Reactor("HOT").(hotsyncReactor) if ok { hotR.SwitchToHotSync(state, int32(blocksSynced)) + conR, ok := bcR.Switch.Reactor("CONSENSUS").(consensusReactor) + if ok { + conR.SwitchToCatchUp() + } } else { // should only happen during testing } diff --git a/blockchain/v1/reactor.go b/blockchain/v1/reactor.go index fbb0fdf6a..1caf07dac 100644 --- a/blockchain/v1/reactor.go +++ b/blockchain/v1/reactor.go @@ -49,6 +49,7 @@ type consensusReactor interface { // for when we switch from blockchain reactor and fast sync to // the consensus machine SwitchToConsensus(sm.State, int) + SwitchToCatchUp() } // BlockchainReactor handles long-term catchup syncing. @@ -496,6 +497,10 @@ func (bcR *BlockchainReactor) switchToConsensusOrHotSync() { hotR, ok := bcR.Switch.Reactor("HOT").(hotsyncReactor) if ok { hotR.SwitchToHotSync(bcR.state, int32(bcR.blocksSynced)) + conR, ok := bcR.Switch.Reactor("CONSENSUS").(consensusReactor) + if ok { + conR.SwitchToCatchUp() + } } else { // should only happen during testing } diff --git a/consensus/reactor.go b/consensus/reactor.go index 6f0be14c3..8fc06e303 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -97,6 +97,13 @@ func (conR *ConsensusReactor) OnStop() { } } +func (conR *ConsensusReactor) SwitchToCatchUp() { + conR.mtx.Lock() + conR.fastSync = false + conR.mtx.Unlock() + conR.metrics.FastSyncing.Set(0) +} + // SwitchToConsensus switches from fast_sync mode to consensus mode. // It resets the state, turns off fast_sync, and starts the consensus state-machine func (conR *ConsensusReactor) SwitchToConsensus(state sm.State, blocksSynced int) {