Skip to content

Commit

Permalink
refactor: move remaining LogPrintf usage outside
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Dec 15, 2024
1 parent 9f9324e commit 04523fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainstateLoadVerifyError> rv2;
try {
uiInterface.InitMessage(_("Verifying blocks…").translated);
Expand All @@ -1954,7 +1958,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
chainparams.GetConsensus(),
check_blocks,
args.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
static_cast<int64_t(*)()>(GetTime));
static_cast<int64_t(*)()>(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;
Expand Down
11 changes: 4 additions & 7 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ std::optional<ChainstateLoadingError> 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) {
Expand Down Expand Up @@ -278,7 +274,8 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
const Consensus::Params& consensus_params,
unsigned int check_blocks,
unsigned int check_level,
std::function<int64_t()> get_unix_time_seconds)
std::function<int64_t()> get_unix_time_seconds,
std::function<void(bool)> notify_bls_state)
{
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
Expand All @@ -295,7 +292,7 @@ std::optional<ChainstateLoadVerifyError> 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(
Expand All @@ -310,7 +307,7 @@ std::optional<ChainstateLoadVerifyError> 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) {
Expand Down
3 changes: 2 additions & 1 deletion src/node/chainstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
const Consensus::Params& consensus_params,
unsigned int check_blocks,
unsigned int check_level,
std::function<int64_t()> get_unix_time_seconds);
std::function<int64_t()> get_unix_time_seconds,
std::function<void(bool)> notify_bls_state = nullptr);

#endif // BITCOIN_NODE_CHAINSTATE_H

0 comments on commit 04523fc

Please sign in to comment.