mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
validation: Prune UnloadBlockIndex and callees
In previous commits in this patchset, we've made sure that every Unload/UnloadBlockIndex member function resets its own members, and does not reach out to globals. This means that their corresponding classes' default destructors can now replace them, and do an even more thorough job without the need to be updated for every new member variable. Therefore, we can remove them, and also remove UnloadBlockIndex since that's not used anymore. Unfortunately, chainstatemanager_loadblockindex relies on CChainState::UnloadBlockIndex, so that needs to stay for now.
This commit is contained in:
@@ -4143,15 +4143,6 @@ void CChainState::UnloadBlockIndex()
|
||||
setBlockIndexCandidates.clear();
|
||||
}
|
||||
|
||||
// May NOT be used after any connections are up as much
|
||||
// of the peer-processing logic assumes a consistent
|
||||
// block index state
|
||||
void UnloadBlockIndex(ChainstateManager& chainman)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
chainman.Unload();
|
||||
}
|
||||
|
||||
bool ChainstateManager::LoadBlockIndex()
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
@@ -5182,20 +5173,6 @@ bool ChainstateManager::IsSnapshotActive() const
|
||||
return m_snapshot_chainstate && m_active_chainstate == m_snapshot_chainstate.get();
|
||||
}
|
||||
|
||||
void ChainstateManager::Unload()
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
for (CChainState* chainstate : this->GetAll()) {
|
||||
chainstate->m_chain.SetTip(nullptr);
|
||||
chainstate->UnloadBlockIndex();
|
||||
}
|
||||
|
||||
m_failed_blocks.clear();
|
||||
m_blockman.Unload();
|
||||
m_best_header = nullptr;
|
||||
m_best_invalid = nullptr;
|
||||
}
|
||||
|
||||
void ChainstateManager::MaybeRebalanceCaches()
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
@@ -5230,7 +5207,6 @@ void ChainstateManager::MaybeRebalanceCaches()
|
||||
ChainstateManager::~ChainstateManager()
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
UnloadBlockIndex(*this);
|
||||
|
||||
// TODO: The version bits cache and warning cache should probably become
|
||||
// non-globals
|
||||
|
||||
Reference in New Issue
Block a user