aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2022-01-11 15:11:56 -0500
committerCarl Dong <contact@carldong.me>2022-04-27 11:13:38 -0400
commit7d99d725cdb5428ed25dc07c2d7fddf420da7786 (patch)
treea7dcf8484d71799d7aae148fd7c7a9f2a5e5c7e3
parent572d8319272ae84a81d6bfd53dd9685585697f65 (diff)
validation: No mempool clearing in UnloadBlockIndex
The only caller that uses this is ~ChainTestingSetup() where we immediately destroy the mempool afterwards.
-rw-r--r--src/bitcoin-chainstate.cpp2
-rw-r--r--src/test/util/setup_common.cpp2
-rw-r--r--src/validation.cpp5
-rw-r--r--src/validation.h2
4 files changed, 5 insertions, 6 deletions
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index fcbb6aacce..973b866ec8 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -256,7 +256,7 @@ epilogue:
}
GetMainSignals().UnregisterBackgroundSignalScheduler();
- WITH_LOCK(::cs_main, UnloadBlockIndex(nullptr, chainman));
+ WITH_LOCK(::cs_main, UnloadBlockIndex(chainman));
init::UnsetGlobals();
}
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 1830ec05af..3959bf7ae7 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -182,7 +182,7 @@ ChainTestingSetup::~ChainTestingSetup()
m_node.addrman.reset();
m_node.netgroupman.reset();
m_node.args = nullptr;
- WITH_LOCK(::cs_main, UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman));
+ WITH_LOCK(::cs_main, UnloadBlockIndex(*m_node.chainman));
m_node.mempool.reset();
m_node.scheduler.reset();
m_node.chainman.reset();
diff --git a/src/validation.cpp b/src/validation.cpp
index 8448e45051..70762a3a51 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4146,11 +4146,10 @@ void CChainState::UnloadBlockIndex()
// May NOT be used after any connections are up as much
// of the peer-processing logic assumes a consistent
// block index state
-void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
+void UnloadBlockIndex(ChainstateManager& chainman)
{
AssertLockHeld(::cs_main);
chainman.Unload();
- if (mempool) mempool->clear();
}
bool ChainstateManager::LoadBlockIndex()
@@ -5231,7 +5230,7 @@ void ChainstateManager::MaybeRebalanceCaches()
ChainstateManager::~ChainstateManager()
{
LOCK(::cs_main);
- UnloadBlockIndex(/*mempool=*/nullptr, *this);
+ UnloadBlockIndex(*this);
// TODO: The version bits cache and warning cache should probably become
// non-globals
diff --git a/src/validation.h b/src/validation.h
index 3996086ced..5fb7c5b4cf 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -135,7 +135,7 @@ extern arith_uint256 nMinimumChainWork;
extern const std::vector<std::string> CHECKLEVEL_DOC;
/** Unload database information */
-void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
+void UnloadBlockIndex(ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
/** Run instances of script checking worker threads */
void StartScriptCheckWorkerThreads(int threads_num);
/** Stop all of the script checking worker threads */