mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
validation: Pass in chainman to UnloadBlockIndex
This commit is contained in:
parent
4668ded6d6
commit
74f73c783d
5 changed files with 10 additions and 7 deletions
|
@ -1559,7 +1559,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||||
chainman.m_total_coinstip_cache = nCoinCacheUsage;
|
chainman.m_total_coinstip_cache = nCoinCacheUsage;
|
||||||
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
||||||
|
|
||||||
UnloadBlockIndex(node.mempool.get());
|
UnloadBlockIndex(node.mempool.get(), chainman);
|
||||||
|
|
||||||
// new CBlockTreeDB tries to delete the existing file, which
|
// new CBlockTreeDB tries to delete the existing file, which
|
||||||
// fails if it's still open from the previous loop. Close it first:
|
// fails if it's still open from the previous loop. Close it first:
|
||||||
|
|
|
@ -84,8 +84,11 @@ void AppTests::appTests()
|
||||||
// Reset global state to avoid interfering with later tests.
|
// Reset global state to avoid interfering with later tests.
|
||||||
LogInstance().DisconnectTestLogger();
|
LogInstance().DisconnectTestLogger();
|
||||||
AbortShutdown();
|
AbortShutdown();
|
||||||
UnloadBlockIndex(/* mempool */ nullptr);
|
{
|
||||||
WITH_LOCK(::cs_main, g_chainman.Reset());
|
LOCK(cs_main);
|
||||||
|
UnloadBlockIndex(/* mempool */ nullptr, g_chainman);
|
||||||
|
g_chainman.Reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Entry point for BitcoinGUI tests.
|
//! Entry point for BitcoinGUI tests.
|
||||||
|
|
|
@ -187,7 +187,7 @@ TestingSetup::~TestingSetup()
|
||||||
m_node.connman.reset();
|
m_node.connman.reset();
|
||||||
m_node.banman.reset();
|
m_node.banman.reset();
|
||||||
m_node.args = nullptr;
|
m_node.args = nullptr;
|
||||||
UnloadBlockIndex(m_node.mempool.get());
|
UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman);
|
||||||
m_node.mempool.reset();
|
m_node.mempool.reset();
|
||||||
m_node.scheduler.reset();
|
m_node.scheduler.reset();
|
||||||
m_node.chainman->Reset();
|
m_node.chainman->Reset();
|
||||||
|
|
|
@ -4605,10 +4605,10 @@ void CChainState::UnloadBlockIndex() {
|
||||||
// May NOT be used after any connections are up as much
|
// May NOT be used after any connections are up as much
|
||||||
// of the peer-processing logic assumes a consistent
|
// of the peer-processing logic assumes a consistent
|
||||||
// block index state
|
// block index state
|
||||||
void UnloadBlockIndex(CTxMemPool* mempool)
|
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
g_chainman.Unload();
|
chainman.Unload();
|
||||||
pindexBestInvalid = nullptr;
|
pindexBestInvalid = nullptr;
|
||||||
pindexBestHeader = nullptr;
|
pindexBestHeader = nullptr;
|
||||||
if (mempool) mempool->clear();
|
if (mempool) mempool->clear();
|
||||||
|
|
|
@ -159,7 +159,7 @@ void LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, FlatFi
|
||||||
/** Ensures we have a genesis block in the block tree, possibly writing one to disk. */
|
/** Ensures we have a genesis block in the block tree, possibly writing one to disk. */
|
||||||
bool LoadGenesisBlock(const CChainParams& chainparams);
|
bool LoadGenesisBlock(const CChainParams& chainparams);
|
||||||
/** Unload database information */
|
/** Unload database information */
|
||||||
void UnloadBlockIndex(CTxMemPool* mempool);
|
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman);
|
||||||
/** Run an instance of the script checking thread */
|
/** Run an instance of the script checking thread */
|
||||||
void ThreadScriptCheck(int worker_num);
|
void ThreadScriptCheck(int worker_num);
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue