Skip to content

Commit 74f73c7

Browse files
committed
validation: Pass in chainman to UnloadBlockIndex
1 parent 4668ded commit 74f73c7

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
15591559
chainman.m_total_coinstip_cache = nCoinCacheUsage;
15601560
chainman.m_total_coinsdb_cache = nCoinDBCache;
15611561

1562-
UnloadBlockIndex(node.mempool.get());
1562+
UnloadBlockIndex(node.mempool.get(), chainman);
15631563

15641564
// new CBlockTreeDB tries to delete the existing file, which
15651565
// fails if it's still open from the previous loop. Close it first:

src/qt/test/apptests.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ void AppTests::appTests()
8484
// Reset global state to avoid interfering with later tests.
8585
LogInstance().DisconnectTestLogger();
8686
AbortShutdown();
87-
UnloadBlockIndex(/* mempool */ nullptr);
88-
WITH_LOCK(::cs_main, g_chainman.Reset());
87+
{
88+
LOCK(cs_main);
89+
UnloadBlockIndex(/* mempool */ nullptr, g_chainman);
90+
g_chainman.Reset();
91+
}
8992
}
9093

9194
//! Entry point for BitcoinGUI tests.

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ TestingSetup::~TestingSetup()
187187
m_node.connman.reset();
188188
m_node.banman.reset();
189189
m_node.args = nullptr;
190-
UnloadBlockIndex(m_node.mempool.get());
190+
UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman);
191191
m_node.mempool.reset();
192192
m_node.scheduler.reset();
193193
m_node.chainman->Reset();

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4605,10 +4605,10 @@ void CChainState::UnloadBlockIndex() {
46054605
// May NOT be used after any connections are up as much
46064606
// of the peer-processing logic assumes a consistent
46074607
// block index state
4608-
void UnloadBlockIndex(CTxMemPool* mempool)
4608+
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
46094609
{
46104610
LOCK(cs_main);
4611-
g_chainman.Unload();
4611+
chainman.Unload();
46124612
pindexBestInvalid = nullptr;
46134613
pindexBestHeader = nullptr;
46144614
if (mempool) mempool->clear();

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
159159
/** Ensures we have a genesis block in the block tree, possibly writing one to disk. */
160160
bool LoadGenesisBlock(const CChainParams& chainparams);
161161
/** Unload database information */
162-
void UnloadBlockIndex(CTxMemPool* mempool);
162+
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman);
163163
/** Run an instance of the script checking thread */
164164
void ThreadScriptCheck(int worker_num);
165165
/**

0 commit comments

Comments
 (0)