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.
This commit is contained in:
Carl Dong
2021-08-18 13:39:34 -04:00
parent ca7c0b934d
commit b345979a2b
3 changed files with 15 additions and 10 deletions

View File

@@ -1427,7 +1427,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
fReindexChainState,
nBlockTreeDBCache,
nCoinDBCache,
nCoinCacheUsage);
nCoinCacheUsage,
[]() {
uiInterface.ThreadSafeMessageBox(
_("Error reading from database, shutting down."),
"", CClientUIInterface::MSG_ERROR);
});
if (rv.has_value()) {
switch (rv.value()) {
case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB:
@@ -1463,6 +1468,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
break;
}
} else {
uiInterface.InitMessage(_("Verifying blocks…").translated);
auto rv2 = VerifyLoadedChainstate(chainman,
fReset,
fReindexChainState,