Page MenuHomePhabricator

validation: Move ~CMainCleanup logic to ~BlockManager
ClosedPublic

Authored by PiRK on Jul 20 2021, 16:21.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC37142f8783a6: validation: Move ~CMainCleanup logic to ~BlockManager
Summary

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:

  1. Is vestigial
  2. References the g_chainman global (we should minimize g_chainman refs)
  3. Only acts on g_chainman.m_blockman
  4. 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.

Test Plan

ninja all check-all