HomePhabricator

validation: Move ~CMainCleanup logic to ~BlockManager

Description

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

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9820

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Sep 8 2020, 18:36
PiRKCommitted on Jul 21 2021, 07:01
PiRKPushed on Jul 21 2021, 07:01
Reviewer
Restricted Project
Differential Revision
D9820: validation: Move ~CMainCleanup logic to ~BlockManager
Parents
rABCd6cc6acd5065: [avalanche] Track the time of the last new proof received
Branches
Unknown
Tags
Unknown