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:
Carl Dong
2021-01-12 13:38:53 -05:00
parent 7d99d725cd
commit 7ab07e0332
6 changed files with 0 additions and 54 deletions

View File

@@ -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