mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
validation: Don't loop over all chainstates in LoadExternalBlock
This simplifies the code. The only reason to call ActivateBestChain() here is to allow the main init thread to finish startup in a case of -reindex. In this situation no second chainstate can exist anyway because -reindex would have deleted any snapshot chainstate earlier. This could change behavior slightly if -loadblocks was used when there is a snapshot chainstate. In this case, there is no reason to call ActivateBestChain() for that chainstate here - it will be called in ImportBlocks() after all blocks have been indexed.
This commit is contained in:
parent
22723c809a
commit
a2675897e2
1 changed files with 2 additions and 9 deletions
|
@ -5158,15 +5158,8 @@ void ChainstateManager::LoadExternalBlockFile(
|
||||||
|
|
||||||
// Activate the genesis block so normal node progress can continue
|
// Activate the genesis block so normal node progress can continue
|
||||||
if (hash == params.GetConsensus().hashGenesisBlock) {
|
if (hash == params.GetConsensus().hashGenesisBlock) {
|
||||||
bool genesis_activation_failure = false;
|
BlockValidationState state;
|
||||||
for (auto c : GetAll()) {
|
if (!ActiveChainstate().ActivateBestChain(state, nullptr)) {
|
||||||
BlockValidationState state;
|
|
||||||
if (!c->ActivateBestChain(state, nullptr)) {
|
|
||||||
genesis_activation_failure = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (genesis_activation_failure) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue