Page MenuHomePhabricator

node/chainstate: Decouple from stringy errors
ClosedPublic

Authored by Fabien on Nov 21 2022, 14:32.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCb9aeba3d9ca9: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Nov 21 2022, 14:32
PiRK requested changes to this revision.Nov 21 2022, 15:42
PiRK added a subscriber: PiRK.
PiRK added inline comments.
src/init.cpp
2658 ↗(On Diff #36437)

Is this message not going to be overwritten by the fallthrough?

src/node/chainstate.cpp
15 ↗(On Diff #36437)

Why keep this?

62 ↗(On Diff #36437)
src/node/chainstate.h
18 ↗(On Diff #36437)
This revision now requires changes to proceed.Nov 21 2022, 15:42
src/init.cpp
2658 ↗(On Diff #36437)

Ouch, good catch

Fix typo, remove useless header, properly break in the switch

This revision is now accepted and ready to land.Nov 21 2022, 18:38