HomePhabricator

move-only-ish: init: factor out chainstate initialization

Description

move-only-ish: init: factor out chainstate initialization

Summary:
Moves chainstate initialization into its own function. This is
necessary to later support a more readable way of handling
background-validation chainstate cleanup during init, since the
chainstate initialization functions may need to be repeated after
moving leveldb filesystem content around.

This commit isn't strictly necessary, but the alternative is to (ab)use
the while loop in init.cpp with a continue on the basis of a
specific ChainstateLoadingError return value from LoadChainstate. Not
only is this harder to read, but it can't be unittested.

The approach here lets us consolidate background-validation cleanup to
LoadChainstate, and therefore exercise it within tests.

This commit is most easily reviewed with

git diff --color-moved=dimmed-zebra
--color-moved-ws=ignore-space-change

This is a partial backport of core#25740
https://github.com/bitcoin/bitcoin/pull/25740/commits/f2a4f3376f1476b38a79a549bd81ba3006225df6

Depends on D14685

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
James O'Beirne <james.obeirne@pm.me>Authored on Nov 3 2022, 18:37
PiRKCommitted on Oct 26 2023, 11:39
PiRKPushed on Oct 26 2023, 11:39
Reviewer
Restricted Project
Differential Revision
D14686: move-only-ish: init: factor out chainstate initialization
Parents
rABCb9af6d5b906c: validation: add CChainState::m_disabled and ChainMan::isUsable
Branches
Unknown
Tags
Unknown