@@ -196,8 +196,8 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
196
196
std::unique_ptr<CBlockTreeDB> pblocktree;
197
197
198
198
// See definition for documentation
199
- static void FindFilesToPruneManual (std::set<int >& setFilesToPrune, int nManualPruneHeight);
200
- static void FindFilesToPrune (std::set<int >& setFilesToPrune, uint64_t nPruneAfterHeight);
199
+ static void FindFilesToPruneManual (ChainstateManager& chainman, std::set<int >& setFilesToPrune, int nManualPruneHeight);
200
+ static void FindFilesToPrune (ChainstateManager& chainman, std::set<int >& setFilesToPrune, uint64_t nPruneAfterHeight);
201
201
bool CheckInputScripts (const CTransaction& tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData& txdata, std::vector<CScriptCheck> *pvChecks = nullptr );
202
202
static FILE* OpenUndoFile (const FlatFilePos &pos, bool fReadOnly = false );
203
203
static FlatFileSeq BlockFileSeq ();
@@ -2282,11 +2282,11 @@ bool CChainState::FlushStateToDisk(
2282
2282
if (nManualPruneHeight > 0 ) {
2283
2283
LOG_TIME_MILLIS_WITH_CATEGORY (" find files to prune (manual)" , BCLog::BENCH);
2284
2284
2285
- FindFilesToPruneManual (setFilesToPrune, nManualPruneHeight);
2285
+ FindFilesToPruneManual (g_chainman, setFilesToPrune, nManualPruneHeight);
2286
2286
} else {
2287
2287
LOG_TIME_MILLIS_WITH_CATEGORY (" find files to prune" , BCLog::BENCH);
2288
2288
2289
- FindFilesToPrune (setFilesToPrune, chainparams.PruneAfterHeight ());
2289
+ FindFilesToPrune (g_chainman, setFilesToPrune, chainparams.PruneAfterHeight ());
2290
2290
fCheckForPruning = false ;
2291
2291
}
2292
2292
if (!setFilesToPrune.empty ()) {
@@ -3895,12 +3895,12 @@ uint64_t CalculateCurrentUsage()
3895
3895
return retval;
3896
3896
}
3897
3897
3898
- /* Prune a block file (modify associated database entries)*/
3899
- void PruneOneBlockFile (const int fileNumber)
3898
+ void ChainstateManager::PruneOneBlockFile (const int fileNumber)
3900
3899
{
3900
+ AssertLockHeld (cs_main);
3901
3901
LOCK (cs_LastBlockFile);
3902
3902
3903
- for (const auto & entry : g_chainman. BlockIndex () ) {
3903
+ for (const auto & entry : m_blockman. m_block_index ) {
3904
3904
CBlockIndex* pindex = entry.second ;
3905
3905
if (pindex->nFile == fileNumber) {
3906
3906
pindex->nStatus &= ~BLOCK_HAVE_DATA;
@@ -3914,12 +3914,12 @@ void PruneOneBlockFile(const int fileNumber)
3914
3914
// to be downloaded again in order to consider its chain, at which
3915
3915
// point it would be considered as a candidate for
3916
3916
// m_blocks_unlinked or setBlockIndexCandidates.
3917
- auto range = g_chainman. m_blockman .m_blocks_unlinked .equal_range (pindex->pprev );
3917
+ auto range = m_blockman.m_blocks_unlinked .equal_range (pindex->pprev );
3918
3918
while (range.first != range.second ) {
3919
3919
std::multimap<CBlockIndex *, CBlockIndex *>::iterator _it = range.first ;
3920
3920
range.first ++;
3921
3921
if (_it->second == pindex) {
3922
- g_chainman. m_blockman .m_blocks_unlinked .erase (_it);
3922
+ m_blockman.m_blocks_unlinked .erase (_it);
3923
3923
}
3924
3924
}
3925
3925
}
@@ -3941,7 +3941,7 @@ void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune)
3941
3941
}
3942
3942
3943
3943
/* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
3944
- static void FindFilesToPruneManual (std::set<int >& setFilesToPrune, int nManualPruneHeight)
3944
+ static void FindFilesToPruneManual (ChainstateManager& chainman, std::set<int >& setFilesToPrune, int nManualPruneHeight)
3945
3945
{
3946
3946
assert (fPruneMode && nManualPruneHeight > 0 );
3947
3947
@@ -3955,7 +3955,7 @@ static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPr
3955
3955
for (int fileNumber = 0 ; fileNumber < nLastBlockFile; fileNumber++) {
3956
3956
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
3957
3957
continue ;
3958
- PruneOneBlockFile (fileNumber);
3958
+ chainman. PruneOneBlockFile (fileNumber);
3959
3959
setFilesToPrune.insert (fileNumber);
3960
3960
count++;
3961
3961
}
@@ -3988,7 +3988,7 @@ void PruneBlockFilesManual(int nManualPruneHeight)
3988
3988
*
3989
3989
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
3990
3990
*/
3991
- static void FindFilesToPrune (std::set<int >& setFilesToPrune, uint64_t nPruneAfterHeight)
3991
+ static void FindFilesToPrune (ChainstateManager& chainman, std::set<int >& setFilesToPrune, uint64_t nPruneAfterHeight)
3992
3992
{
3993
3993
LOCK2 (cs_main, cs_LastBlockFile);
3994
3994
if (::ChainActive ().Tip () == nullptr || nPruneTarget == 0 ) {
@@ -4030,7 +4030,7 @@ static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfte
4030
4030
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
4031
4031
continue ;
4032
4032
4033
- PruneOneBlockFile (fileNumber);
4033
+ chainman. PruneOneBlockFile (fileNumber);
4034
4034
// Queue up the files for removal
4035
4035
setFilesToPrune.insert (fileNumber);
4036
4036
nCurrentUsage -= nBytesToPrune;
0 commit comments