PR description:
This PR paves the way for de-globalizing g_chainman entirely by removing the usage of g_chainman in the following functions/methods:
- ~CMainCleanup
- CChainState::FlushStateToDisk
- UnloadBlockIndex
The remaining direct uses of g_chainman are as follows:
- In initialization codepaths:
- AppTests
- AppInitMain
- TestingSetup::TestingSetup
- ::ChainstateActive
- LookupBlockIndex Note: LookupBlockIndex is used extensively throughout the codebase and require a much larger set of changes, therefore I've left it out of this initial PR
~CMainCleanup:
- Is vestigial
- References the g_chainman global (we should minimize g_chainman refs)
- Only acts on g_chainman.m_blockman
- Does the same thing as BlockManager::Unload
This is a backport of core#19927 [1/6]
https://github.com/bitcoin/bitcoin/pull/19927/commits/4668ded6d6ea4299d998abbb57543f37519812e2
Backport note: there were 7 commits in the original PR, but one of those commits is only touching style and is not relevant to us as the linter already fixed the style.