Commit graph

15 commits

Author SHA1 Message Date
Carl Dong
4da9c076d1 node/chainstate: Decouple from ShutdownRequested
...instead allow optionally passing in a std::function<bool()>
2021-12-07 14:48:49 -05:00
Carl Dong
05441c2dc5 node/chainstate: Decouple from GetTime
...instead pass in a std::function<int64_t()>

Note that the static_cast is needed (apparently) for the compiler to
know which overloaded GetTime to choose.
2021-12-07 14:48:49 -05:00
Carl Dong
2414ebc18b init: Delay RPC block notif until warmup finished
See added code comment for more details.
2021-12-07 14:48:06 -05:00
Carl Dong
8d466a8504 Move -checkblocks LogPrintf to AppInitMain 2021-12-06 16:41:58 -05:00
Carl Dong
aad8d59789 node/chainstate: Reduce coupling of LogPrintf
...by moving the try/catch out of LoadChainstate

I strongly recommend reviewing with the following git-diff flags:
  --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change
2021-12-06 16:41:58 -05:00
Carl Dong
b345979a2b node/chainstate: Decouple from concept of uiInterface
...instead allow the caller to optionally pass in callbacks which are
triggered for certain events.

Behaviour change: The string "Verifying blocks..." was previously
printed for each chainstate in chainman which did not have an
effectively empty coinsview, now it will be printed once unconditionally
before we call VerifyLoadedChain.
2021-12-06 16:41:33 -05:00
Carl Dong
ca7c0b934d Split off VerifyLoadedChainstate 2021-12-06 15:58:10 -05:00
Carl Dong
adf4912d77 node/chainstate: Remove do/while loop
I strongly recommend reviewing with the following git-diff flags:
  --ignore-space-change
2021-12-06 15:57:46 -05:00
Carl Dong
975235ca0a Move init logistics message for BAD_GENESIS_BLOCK to init.cpp 2021-12-06 15:56:55 -05:00
Carl Dong
8715658983 Move mempool nullptr Assert out of LoadChainstate 2021-12-06 15:56:55 -05:00
Carl Dong
9162a4f93e node/chainstate: Decouple from concept of NodeContext
...instead pass in only the necessary information

Also allow mempool to be a nullptr
2021-12-06 15:56:55 -05:00
Carl Dong
c7a5c46e6f node/chainstate: Decouple from ArgsManager
...instead pass in only the necessary information
2021-12-06 15:56:55 -05:00
Carl Dong
ae9121f958 node/chainstate: Decouple from stringy errors
This allows us to separate the initialization code from translations and
error reporting.

This change changes the caller semantics of LoadChainstate quite
drastically.

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.
2021-12-06 15:56:50 -05:00
Carl Dong
cbac28b72f node/chainstate: Decouple from GetTimeMillis
...instead just move it out
2021-12-06 15:55:49 -05:00
Carl Dong
cb64af9635 node: Extract chainstate loading sequence
I strongly recommend reviewing with the following git-diff flags:
  --color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change

[META] 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

----

[META] This semantic will change in a future commit named
       "node/chainstate: Decouple from stringy errors"
2021-12-06 15:55:16 -05:00