diff options
author | Carl Dong <contact@carldong.me> | 2020-09-15 15:59:46 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-03-01 17:56:07 -0500 |
commit | 63e4c7316a537900f525e221d8042587b443cc3d (patch) | |
tree | fd7a4e43848b6126e7860a21dd2f5e877a3cdf46 | |
parent | 4bada76237d734c1de38d3bd58689caeefd5e8cb (diff) | |
download | bitcoin-63e4c7316a537900f525e221d8042587b443cc3d.tar.xz |
validation: Pass in chainstate to ::PruneBlockFilesManual
-rw-r--r-- | src/rpc/blockchain.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 5 | ||||
-rw-r--r-- | src/validation.h | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index bb6c7e32ef..568b3d98ac 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -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)) { diff --git a/src/validation.cpp b/src/validation.cpp index f7faa12458..95fb3f6864 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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()); } diff --git a/src/validation.h b/src/validation.h index 73b17c6353..9855c131e1 100644 --- a/src/validation.h +++ b/src/validation.h @@ -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. |