Clear {versionbits,warning}cache in ~Chainstatemanager
Also add TODO item to deglobalize the {versionbits,warning}cache, which
should really only need to be cleared if we change the chainparams.
This commit is contained in:
1 parent
eca4ca4d60
commit
572d831927
2 files changed
+14
-8
No files matched your search
+13
-4
@@ -4151,10 +4151,6 @@ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
|
|||||||
AssertLockHeld(::cs_main);
|
AssertLockHeld(::cs_main);
|
||||||
chainman.Unload();
|
chainman.Unload();
|
||||||
if (mempool) mempool->clear();
|
if (mempool) mempool->clear();
|
||||||
g_versionbitscache.Clear();
|
|
||||||
for (auto& i : warningcache) {
|
|
||||||
i.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChainstateManager::LoadBlockIndex()
|
bool ChainstateManager::LoadBlockIndex()
|
||||||
@@ -5231,3 +5227,16 @@ void ChainstateManager::MaybeRebalanceCaches()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChainstateManager::~ChainstateManager()
|
||||||
|
{
|
||||||
|
LOCK(::cs_main);
|
||||||
|
UnloadBlockIndex(/*mempool=*/nullptr, *this);
|
||||||
|
|
||||||
|
// TODO: The version bits cache and warning cache should probably become
|
||||||
|
// non-globals
|
||||||
|
g_versionbitscache.Clear();
|
||||||
|
for (auto& i : warningcache) {
|
||||||
|
i.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-4
@@ -995,10 +995,7 @@ public:
|
|||||||
//! ResizeCoinsCaches() as needed.
|
//! ResizeCoinsCaches() as needed.
|
||||||
void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
void MaybeRebalanceCaches() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||||
|
|
||||||
~ChainstateManager() {
|
~ChainstateManager();
|
||||||
LOCK(::cs_main);
|
|
||||||
UnloadBlockIndex(/*mempool=*/nullptr, *this);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
|
using FopenFn = std::function<FILE*(const fs::path&, const char*)>;
|
||||||
|
|||||||
Reference in new issue
Block a user