Clear pindexBestHeader in ChainstateManager::Unload()

-----

Code Reviewer Notes

Call graph of relevant functions:

UnloadBlockIndex() <-- Moved from
    calls ChainstateManager::Unload() <-- Moved to

Safe because ChainstateManager::Unload() is called only by
UnloadBlockIndex() and no other callers.
This commit is contained in:
Carl Dong 2022-02-23 15:21:09 -05:00
parent 73eedaaacc
commit c96524113c

View File

@ -4122,7 +4122,6 @@ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
{
AssertLockHeld(::cs_main);
chainman.Unload();
chainman.pindexBestHeader = nullptr;
if (mempool) mempool->clear();
g_versionbitscache.Clear();
for (int b = 0; b < VERSIONBITS_NUM_BITS; b++) {
@ -5171,6 +5170,7 @@ void ChainstateManager::Unload()
m_failed_blocks.clear();
m_blockman.Unload();
pindexBestHeader = nullptr;
m_best_invalid = nullptr;
}