Page MenuHomePhabricator

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

Authored by PiRK on Oct 25 2023, 06:21.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC004abc8d7eee: 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

Event Timeline

PiRK requested review of this revision.Oct 25 2023, 06:21
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/node/chainstate.cpp
163

Note that core moved this to chainman, which makes sense. Unrelated to this diff though

170

dito

175

dito

This revision is now accepted and ready to land.Oct 25 2023, 09:42