From 19746513b168f210a784dc772d1488f93cb4a2e3 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 15 Dec 2024 10:15:34 +0000 Subject: [PATCH] refactor: move remaining `LogPrintf` usage outside --- src/init.cpp | 9 ++++++++- src/node/chainstate.cpp | 11 ++++------- src/node/chainstate.h | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 98da55a3c7..fcb64c7571 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1939,6 +1939,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) break; } } else { + LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled"); + LogPrintf("%s: timestamp index %s\n", __func__, fTimestampIndex ? "enabled" : "disabled"); + LogPrintf("%s: spent index %s\n", __func__, fSpentIndex ? "enabled" : "disabled"); + std::optional rv2; try { uiInterface.InitMessage(_("Verifying blocks…").translated); @@ -1954,7 +1958,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) chainparams.GetConsensus(), check_blocks, args.GetArg("-checklevel", DEFAULT_CHECKLEVEL), - static_cast(GetTime)); + static_cast(GetTime), + [](bool bls_state) { + LogPrintf("%s: bls_legacy_scheme=%d\n", __func__, bls_state); + }); } catch (const std::exception& e) { LogPrintf("%s\n", e.what()); rv2 = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE; diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 61bcbe22bd..beeee67477 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -133,10 +133,6 @@ std::optional LoadChainstate(bool fReset, chainman.InitAdditionalIndexes(); - LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled"); - LogPrintf("%s: timestamp index %s\n", __func__, fTimestampIndex ? "enabled" : "disabled"); - LogPrintf("%s: spent index %s\n", __func__, fSpentIndex ? "enabled" : "disabled"); - // Check for changed -prune state. What we are concerned about is a user who has pruned blocks // in the past, but is now trying to run unpruned. if (chainman.m_blockman.m_have_pruned && !fPruneMode) { @@ -277,7 +273,8 @@ std::optional VerifyLoadedChainstate(ChainstateManage const Consensus::Params& consensus_params, unsigned int check_blocks, unsigned int check_level, - std::function get_unix_time_seconds) + std::function get_unix_time_seconds, + std::function notify_bls_state) { auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull(); @@ -294,7 +291,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage const bool v19active{DeploymentActiveAfter(tip, consensus_params, Consensus::DEPLOYMENT_V19)}; if (v19active) { bls::bls_legacy_scheme.store(false); - LogPrintf("%s: bls_legacy_scheme=%d\n", __func__, bls::bls_legacy_scheme.load()); + if (notify_bls_state) notify_bls_state(bls::bls_legacy_scheme.load()); } if (!CVerifyDB().VerifyDB( @@ -309,7 +306,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage // Make sure we use the right scheme. if (v19active && bls::bls_legacy_scheme.load()) { bls::bls_legacy_scheme.store(false); - LogPrintf("%s: bls_legacy_scheme=%d\n", __func__, bls::bls_legacy_scheme.load()); + if (notify_bls_state) notify_bls_state(bls::bls_legacy_scheme.load()); } if (check_level >= 3) { diff --git a/src/node/chainstate.h b/src/node/chainstate.h index 42a92afdf5..aa507b5af3 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -156,6 +156,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage const Consensus::Params& consensus_params, unsigned int check_blocks, unsigned int check_level, - std::function get_unix_time_seconds); + std::function get_unix_time_seconds, + std::function notify_bls_state = nullptr); #endif // BITCOIN_NODE_CHAINSTATE_H