mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
validation: Pass in chainstate to ::PruneBlockFilesManual
This commit is contained in:
parent
4bada76237
commit
63e4c7316a
3 changed files with 5 additions and 4 deletions
|
@ -1015,7 +1015,7 @@ static RPCHelpMan pruneblockchain()
|
|||
height = chainHeight - MIN_BLOCKS_TO_KEEP;
|
||||
}
|
||||
|
||||
PruneBlockFilesManual(height);
|
||||
PruneBlockFilesManual(::ChainstateActive(), height);
|
||||
const CBlockIndex* block = ::ChainActive().Tip();
|
||||
CHECK_NONFATAL(block);
|
||||
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
|
||||
|
|
|
@ -3953,11 +3953,12 @@ void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nM
|
|||
}
|
||||
|
||||
/* This function is called from the RPC code for pruneblockchain */
|
||||
void PruneBlockFilesManual(int nManualPruneHeight)
|
||||
void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight)
|
||||
{
|
||||
BlockValidationState state;
|
||||
const CChainParams& chainparams = Params();
|
||||
if (!::ChainstateActive().FlushStateToDisk(
|
||||
assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
|
||||
if (!active_chainstate.FlushStateToDisk(
|
||||
chainparams, state, FlushStateMode::NONE, nManualPruneHeight)) {
|
||||
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ uint64_t CalculateCurrentUsage();
|
|||
void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune);
|
||||
|
||||
/** Prune block files up to a given height */
|
||||
void PruneBlockFilesManual(int nManualPruneHeight);
|
||||
void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight);
|
||||
|
||||
/**
|
||||
* Validation result for a single transaction mempool acceptance.
|
||||
|
|
Loading…
Add table
Reference in a new issue