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.
  • Loading branch information
mruddy committed Oct 27, 2022
1 parent bd47889 commit 9a2d5ea
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 @@ -4461,6 +4461,21 @@ void Chainstate::LoadExternalBlockFile(
}
}

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);

if (!blocks_with_unknown_parent) continue;
Expand Down

0 comments on commit 9a2d5ea

Please sign in to comment.