Skip to content

Commit 7d99d72

Browse files
committed
validation: No mempool clearing in UnloadBlockIndex
The only caller that uses this is ~ChainTestingSetup() where we immediately destroy the mempool afterwards.
1 parent 572d831 commit 7d99d72

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int main(int argc, char* argv[])
256256
}
257257
GetMainSignals().UnregisterBackgroundSignalScheduler();
258258

259-
WITH_LOCK(::cs_main, UnloadBlockIndex(nullptr, chainman));
259+
WITH_LOCK(::cs_main, UnloadBlockIndex(chainman));
260260

261261
init::UnsetGlobals();
262262
}

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ ChainTestingSetup::~ChainTestingSetup()
182182
m_node.addrman.reset();
183183
m_node.netgroupman.reset();
184184
m_node.args = nullptr;
185-
WITH_LOCK(::cs_main, UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman));
185+
WITH_LOCK(::cs_main, UnloadBlockIndex(*m_node.chainman));
186186
m_node.mempool.reset();
187187
m_node.scheduler.reset();
188188
m_node.chainman.reset();

src/validation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,11 +4146,10 @@ void CChainState::UnloadBlockIndex()
41464146
// May NOT be used after any connections are up as much
41474147
// of the peer-processing logic assumes a consistent
41484148
// block index state
4149-
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
4149+
void UnloadBlockIndex(ChainstateManager& chainman)
41504150
{
41514151
AssertLockHeld(::cs_main);
41524152
chainman.Unload();
4153-
if (mempool) mempool->clear();
41544153
}
41554154

41564155
bool ChainstateManager::LoadBlockIndex()
@@ -5231,7 +5230,7 @@ void ChainstateManager::MaybeRebalanceCaches()
52315230
ChainstateManager::~ChainstateManager()
52325231
{
52335232
LOCK(::cs_main);
5234-
UnloadBlockIndex(/*mempool=*/nullptr, *this);
5233+
UnloadBlockIndex(*this);
52355234

52365235
// TODO: The version bits cache and warning cache should probably become
52375236
// non-globals

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ extern arith_uint256 nMinimumChainWork;
135135
extern const std::vector<std::string> CHECKLEVEL_DOC;
136136

137137
/** Unload database information */
138-
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
138+
void UnloadBlockIndex(ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
139139
/** Run instances of script checking worker threads */
140140
void StartScriptCheckWorkerThreads(int threads_num);
141141
/** Stop all of the script checking worker threads */

0 commit comments

Comments
 (0)