Skip to content

Commit a267589

Browse files
committed
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.
1 parent 22723c8 commit a267589

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/validation.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5158,15 +5158,8 @@ void ChainstateManager::LoadExternalBlockFile(
51585158

51595159
// Activate the genesis block so normal node progress can continue
51605160
if (hash == params.GetConsensus().hashGenesisBlock) {
5161-
bool genesis_activation_failure = false;
5162-
for (auto c : GetAll()) {
5163-
BlockValidationState state;
5164-
if (!c->ActivateBestChain(state, nullptr)) {
5165-
genesis_activation_failure = true;
5166-
break;
5167-
}
5168-
}
5169-
if (genesis_activation_failure) {
5161+
BlockValidationState state;
5162+
if (!ActiveChainstate().ActivateBestChain(state, nullptr)) {
51705163
break;
51715164
}
51725165
}

0 commit comments

Comments
 (0)