From fab262174b96854d2df5bee7da578990c9e9cb1e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 5 Jan 2022 16:23:55 +0100 Subject: [PATCH] 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 --- src/node/blockstorage.cpp | 5 +++++ src/validation.cpp | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 3cc53e27e2c6c..a040f2e7b40f9 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -348,6 +348,11 @@ void BlockManager::Unload() } m_block_index.clear(); + + vinfoBlockFile.clear(); + nLastBlockFile = 0; + setDirtyBlockIndex.clear(); + setDirtyFileInfo.clear(); } bool BlockManager::WriteBlockIndexDB() diff --git a/src/validation.cpp b/src/validation.cpp index 58bced48c9dba..db1a96498cdea 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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();