Move blockstorage-related unload to BlockManager::Unload

This is a refactor and safe to do because:
* UnloadBlockIndex calls ChainstateManager::Unload, which calls
  BlockManager::Unload
* Only unit tests call Unload directly
This commit is contained in:
MarcoFalke 2022-01-05 16:23:55 +01:00
parent fa467f3913
commit fab262174b
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 5 additions and 4 deletions

View file

@ -348,6 +348,11 @@ void BlockManager::Unload()
}
m_block_index.clear();
vinfoBlockFile.clear();
nLastBlockFile = 0;
setDirtyBlockIndex.clear();
setDirtyFileInfo.clear();
}
bool BlockManager::WriteBlockIndexDB()

View file

@ -3980,10 +3980,6 @@ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
chainman.Unload();
pindexBestHeader = nullptr;
if (mempool) mempool->clear();
vinfoBlockFile.clear();
nLastBlockFile = 0;
setDirtyBlockIndex.clear();
setDirtyFileInfo.clear();
g_versionbitscache.Clear();
for (int b = 0; b < VERSIONBITS_NUM_BITS; b++) {
warningcache[b].clear();