diff --git a/src/validation.cpp b/src/validation.cpp index 5ad2ebdcd7e..94b9de3a49e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3567,6 +3567,11 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< m_chainman.MaybeRebalanceCaches(); } + // Write changes periodically to disk, after relay. + if (!FlushStateToDisk(state, FlushStateMode::PERIODIC)) { + return false; + } + if (WITH_LOCK(::cs_main, return m_disabled)) { // Background chainstate has reached the snapshot base block, so exit. @@ -3591,11 +3596,6 @@ bool Chainstate::ActivateBestChain(BlockValidationState& state, std::shared_ptr< m_chainman.CheckBlockIndex(); - // Write changes periodically to disk, after relay. - if (!FlushStateToDisk(state, FlushStateMode::PERIODIC)) { - return false; - } - return true; }