validation: Pass in chainstate to ::PruneBlockFilesManual
This commit is contained in:
1 parent
4bada76237
commit
63e4c7316a
3 files changed
+5
-4
No files matched your search
@@ -1015,7 +1015,7 @@ static RPCHelpMan pruneblockchain()
|
|||||||
height = chainHeight - MIN_BLOCKS_TO_KEEP;
|
height = chainHeight - MIN_BLOCKS_TO_KEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
PruneBlockFilesManual(height);
|
PruneBlockFilesManual(::ChainstateActive(), height);
|
||||||
const CBlockIndex* block = ::ChainActive().Tip();
|
const CBlockIndex* block = ::ChainActive().Tip();
|
||||||
CHECK_NONFATAL(block);
|
CHECK_NONFATAL(block);
|
||||||
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
|
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
|
||||||
|
|||||||
+3
-2
@@ -3953,11 +3953,12 @@ void BlockManager::FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nM
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function is called from the RPC code for pruneblockchain */
|
/* This function is called from the RPC code for pruneblockchain */
|
||||||
void PruneBlockFilesManual(int nManualPruneHeight)
|
void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight)
|
||||||
{
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
if (!::ChainstateActive().FlushStateToDisk(
|
assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
|
||||||
|
if (!active_chainstate.FlushStateToDisk(
|
||||||
chainparams, state, FlushStateMode::NONE, nManualPruneHeight)) {
|
chainparams, state, FlushStateMode::NONE, nManualPruneHeight)) {
|
||||||
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -183,7 +183,7 @@ uint64_t CalculateCurrentUsage();
|
|||||||
void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune);
|
void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune);
|
||||||
|
|
||||||
/** Prune block files up to a given height */
|
/** 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.
|
* Validation result for a single transaction mempool acceptance.
|
||||||
|
|||||||
Reference in new issue
Block a user