diff --git a/src/validation.cpp b/src/validation.cpp index 3e8a7cf520e..b5de3c74adc 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5169,16 +5169,15 @@ void ChainstateManager::LoadExternalBlockFile( } // Activate the genesis block so normal node progress can continue - if (hash == params.GetConsensus().hashGenesisBlock) { - bool genesis_activation_failure = false; - for (auto c : GetAll()) { - BlockValidationState state; - if (!c->ActivateBestChain(state, nullptr)) { - genesis_activation_failure = true; - break; - } - } - if (genesis_activation_failure) { + // During first -reindex, this will only connect Genesis since + // ActivateBestChain only connects blocks which are in the block tree db, + // which only contains blocks whose parents are in it. + // But do this only if genesis isn't activated yet, to avoid connecting many blocks + // without assumevalid in the case of a continuation of a reindex that + // was interrupted by the user. + if (hash == params.GetConsensus().hashGenesisBlock && WITH_LOCK(::cs_main, return ActiveHeight()) == -1) { + BlockValidationState state; + if (!ActiveChainstate().ActivateBestChain(state, nullptr)) { break; } }