node: Extract chainstate loading sequence
Summary:
This commit is intended to be as close to a move-only commit as possible, and lingering ugliness will be resolved in subsequent commits. A few variables that are passed in by value instead of by reference deserve explanation: - fReset and fReindexChainstate are both local variables in AppInitMain and are not modified in the sequence - fPruneMode, despite being a global, is only modified in AppInitParameterInteraction, long before LoadChainstate is called
Partial backport of core#23280:
https://github.com/bitcoin/bitcoin/pull/23280/commits/cb64af9635a9553e335f2dc0b1cca20c6bbd0933
Depends on D12554.
Note: fPruneMode has been renamed in chainstate.cpp to prevent shadowing
the global variable.
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Subscribers: PiRK
Differential Revision: https://reviews.bitcoinabc.org/D12555