HomePhabricator

node/chainstate: Decouple from stringy errors

Description

node/chainstate: Decouple from stringy errors

Summary:

This allows us to separate the initialization code from translations and error reporting.

This change changes the caller semantics of LoadChainstate quitendrastically.

To see that this change doesn't change behaviour, observe that:

1. Prior to this change, LoadChainstate returned false only in the "bad genesis block" failure case (by returning InitError()), indicating that the caller should immediately bail. After this change, the corresponding ERROR_BAD_GENESIS_BLOCK handler in src/init.cpp maintains behavioue by also bailing immediately.

2. The failed_* temporary booleans were only used to break out of the outer do/while(false) loop. They can therefore be safely removed.

Partial backport of core#23280:
https://github.com/bitcoin/bitcoin/pull/23280/commits/ae9121f958a4124ea6238cad0c3f2acb8b9eb4bb#

Depends on D12556.

Test Plan:

ninja all check-extended

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

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

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Aug 17 2021, 22:07
FabienCommitted on Nov 21 2022, 19:28
FabienPushed on Nov 21 2022, 19:28
Reviewer
Restricted Project
Differential Revision
D12557: node/chainstate: Decouple from stringy errors
Parents
rABCd0f1c29cd5c4: node/chainstate: Decouple from GetTimeMillis
Branches
Unknown
Tags
Unknown