Skip to content

Commit 4668ded

Browse files
committed
validation: Move ~CMainCleanup logic to ~BlockManager
~CMainCleanup: 1. Is vestigial 2. References the g_chainman global (we should minimize g_chainman refs) 3. Only acts on g_chainman.m_blockman 4. Does the same thing as BlockManager::Unload
1 parent 147d50d commit 4668ded

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

src/validation.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5226,20 +5226,6 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin
52265226
return std::min<double>(pindex->nChainTx / fTxTotal, 1.0);
52275227
}
52285228

5229-
class CMainCleanup
5230-
{
5231-
public:
5232-
CMainCleanup() {}
5233-
~CMainCleanup() {
5234-
// block headers
5235-
BlockMap::iterator it1 = g_chainman.BlockIndex().begin();
5236-
for (; it1 != g_chainman.BlockIndex().end(); it1++)
5237-
delete (*it1).second;
5238-
g_chainman.BlockIndex().clear();
5239-
}
5240-
};
5241-
static CMainCleanup instance_of_cmaincleanup;
5242-
52435229
Optional<uint256> ChainstateManager::SnapshotBlockhash() const {
52445230
if (m_active_chainstate != nullptr) {
52455231
// If a snapshot chainstate exists, it will always be our active.

src/validation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ class BlockManager {
416416
BlockValidationState& state,
417417
const CChainParams& chainparams,
418418
CBlockIndex** ppindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
419+
420+
~BlockManager() {
421+
Unload();
422+
}
419423
};
420424

421425
/**

0 commit comments

Comments
 (0)