Skip to content

Commit

Permalink
prune, import: fixes bitcoin#23852
Browse files Browse the repository at this point in the history
allows pruning to work during the loadblock import process.

Github-Pull: bitcoin#24957
Rebased-From: da8e95c
  • Loading branch information
mruddy authored and luke-jr committed May 8, 2022
1 parent 42af959 commit c86f129
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4237,6 +4237,21 @@ void CChainState::LoadExternalBlockFile(FILE* fileIn, FlatFilePos* dbp)
}
}

if (fPruneMode && !fReindex) {
// must update the tip for pruning to work while importing with -loadblock.
// this is a tradeoff to conserve disk space at the expense of time
// spent updating the tip to be able to prune.
// otherwise, ActivateBestChain won't be called by the import process
// until after all of the block files are loaded. ActivateBestChain can be
// called by concurrent network message processing. but, that is not
// reliable for the puspose of pruning while importing.
BlockValidationState state;
if (!ActivateBestChain(state, pblock)) {
LogPrint(BCLog::REINDEX, "failed to activate chain (%s)\n", state.ToString());
break;
}
}

NotifyHeaderTip(*this);

// Recursively process earlier encountered successors of this block
Expand Down

0 comments on commit c86f129

Please sign in to comment.