Skip to content

Commit

Permalink
scripted-diff: Update init.cpp to use LogInfo and LogDebug
Browse files Browse the repository at this point in the history
-BEGIN VERIFY SCRIPT-
sed -i 's/LogPrint(\(BCLog::[^,]*\),/LogDebug(\1,/' src/init.cpp
sed -i 's/LogPrintf(/LogInfo(/' src/init.cpp
-END VERIFY SCRIPT-
  • Loading branch information
ajtowns committed Feb 1, 2024
1 parent 698783a commit 6248ea9
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void Shutdown(NodeContext& node)
static Mutex g_shutdown_mutex;
TRY_LOCK(g_shutdown_mutex, lock_shutdown);
if (!lock_shutdown) return;
LogPrintf("%s: In progress...\n", __func__);
LogInfo("%s: In progress...\n", __func__);
Assert(node.args);

/// Note: Shutdown() must be able to handle cases in which initialization failed part of the way,
Expand Down Expand Up @@ -383,7 +383,7 @@ void Shutdown(NodeContext& node)

RemovePidFile(*node.args);

LogPrintf("%s: done\n", __func__);
LogInfo("%s: done\n", __func__);
}

/**
Expand Down Expand Up @@ -437,7 +437,7 @@ static void OnRPCStopped()
rpc_notify_block_change_connection.disconnect();
RPCNotifyBlockChange(nullptr);
g_best_block_cv.notify_all();
LogPrint(BCLog::RPC, "RPC stopped.\n");
LogDebug(BCLog::RPC, "RPC stopped.\n");
}

void SetupServerArgs(ArgsManager& argsman)
Expand Down Expand Up @@ -725,73 +725,73 @@ void InitParameterInteraction(ArgsManager& args)
// even when -connect or -proxy is specified
if (args.IsArgSet("-bind")) {
if (args.SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
LogInfo("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
}
if (args.IsArgSet("-whitebind")) {
if (args.SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
LogInfo("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
}

if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
if (args.SoftSetBoolArg("-dnsseed", false))
LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n", __func__);
LogInfo("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n", __func__);
if (args.SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n", __func__);
LogInfo("%s: parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n", __func__);
}

std::string proxy_arg = args.GetArg("-proxy", "");
if (proxy_arg != "" && proxy_arg != "0") {
// to protect privacy, do not listen by default if a default proxy server is specified
if (args.SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
LogInfo("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
// to protect privacy, do not map ports when a proxy is set. The user may still specify -listen=1
// to listen locally, so don't rely on this happening through -listen below.
if (args.SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
LogInfo("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
if (args.SoftSetBoolArg("-natpmp", false)) {
LogPrintf("%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__);
LogInfo("%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__);
}
// to protect privacy, do not discover addresses by default
if (args.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
LogInfo("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
}

if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) {
// do not map ports or try to retrieve public IP when not listening (pointless)
if (args.SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
LogInfo("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
if (args.SoftSetBoolArg("-natpmp", false)) {
LogPrintf("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
LogInfo("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
}
if (args.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
LogInfo("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
if (args.SoftSetBoolArg("-listenonion", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
LogInfo("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
if (args.SoftSetBoolArg("-i2pacceptincoming", false)) {
LogPrintf("%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__);
LogInfo("%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__);
}
}

if (args.IsArgSet("-externalip")) {
// if an explicit public IP is specified, do not try to find others
if (args.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
LogInfo("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
}

if (args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
// disable whitelistrelay in blocksonly mode
if (args.SoftSetBoolArg("-whitelistrelay", false))
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
LogInfo("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
// Reduce default mempool size in blocksonly mode to avoid unexpected resource usage
if (args.SoftSetArg("-maxmempool", ToString(DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB)))
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", __func__, DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB);
LogInfo("%s: parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", __func__, DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB);
}

// Forcing relay from whitelisted hosts implies we will accept relays from them in the first place.
if (args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
if (args.SoftSetBoolArg("-whitelistrelay", true))
LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
LogInfo("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
}
if (args.IsArgSet("-onlynet")) {
const auto onlynets = args.GetArgs("-onlynet");
Expand All @@ -800,7 +800,7 @@ void InitParameterInteraction(ArgsManager& args)
return n == NET_IPV4 || n == NET_IPV6;
});
if (!clearnet_reachable && args.SoftSetBoolArg("-dnsseed", false)) {
LogPrintf("%s: parameter interaction: -onlynet excludes IPv4 and IPv6 -> setting -dnsseed=0\n", __func__);
LogInfo("%s: parameter interaction: -onlynet excludes IPv4 and IPv6 -> setting -dnsseed=0\n", __func__);
}
}
}
Expand Down Expand Up @@ -890,7 +890,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
// on the command line or in this chain's section of the config file.
ChainType chain = args.GetChainType();
if (chain == ChainType::SIGNET) {
LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
LogInfo("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
}
bilingual_str errors;
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
Expand Down Expand Up @@ -1117,7 +1117,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
return false;
}

LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
LogInfo("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);

// Warn about relative -datadir path.
if (args.IsArgSet("-datadir") && !args.GetPathArg("-datadir").is_absolute()) {
Expand Down Expand Up @@ -1227,9 +1227,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
return false;
}
const uint256 asmap_version = (HashWriter{} << asmap).GetHash();
LogPrintf("Using asmap version %s for IP bucketing\n", asmap_version.ToString());
LogInfo("Using asmap version %s for IP bucketing\n", asmap_version.ToString());
} else {
LogPrintf("Using /16 prefix for IP bucketing\n");
LogInfo("Using /16 prefix for IP bucketing\n");
}

// Initialize netgroup manager
Expand Down Expand Up @@ -1462,16 +1462,16 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// cache size calculations
CacheSizes cache_sizes = CalculateCacheSizes(args, g_enabled_filter_types.size());

LogPrintf("Cache configuration:\n");
LogPrintf("* Using %.1f MiB for block index database\n", cache_sizes.block_tree_db * (1.0 / 1024 / 1024));
LogInfo("Cache configuration:\n");
LogInfo("* Using %.1f MiB for block index database\n", cache_sizes.block_tree_db * (1.0 / 1024 / 1024));
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
LogPrintf("* Using %.1f MiB for transaction index database\n", cache_sizes.tx_index * (1.0 / 1024 / 1024));
LogInfo("* Using %.1f MiB for transaction index database\n", cache_sizes.tx_index * (1.0 / 1024 / 1024));
}
for (BlockFilterType filter_type : g_enabled_filter_types) {
LogPrintf("* Using %.1f MiB for %s block filter index database\n",
LogInfo("* Using %.1f MiB for %s block filter index database\n",
cache_sizes.filter_index * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type));
}
LogPrintf("* Using %.1f MiB for chain state database\n", cache_sizes.coins_db * (1.0 / 1024 / 1024));
LogInfo("* Using %.1f MiB for chain state database\n", cache_sizes.coins_db * (1.0 / 1024 / 1024));

assert(!node.mempool);
assert(!node.chainman);
Expand All @@ -1489,7 +1489,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (mempool_opts.max_size_bytes < 0 || mempool_opts.max_size_bytes < descendant_limit_bytes) {
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(descendant_limit_bytes / 1'000'000.0)));
}
LogPrintf("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", cache_sizes.coins * (1.0 / 1024 / 1024), mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));
LogInfo("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", cache_sizes.coins * (1.0 / 1024 / 1024), mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));

for (bool fLoaded = false; !fLoaded && !ShutdownRequested(node);) {
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
Expand All @@ -1501,7 +1501,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// dependency between validation and index/base, since the latter is not in
// libbitcoinkernel.
chainman.restart_indexes = [&node]() {
LogPrintf("[snapshot] restarting indexes\n");
LogInfo("[snapshot] restarting indexes\n");

// Drain the validation interface queue to ensure that the old indexes
// don't have any pending work.
Expand Down Expand Up @@ -1550,7 +1550,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
std::tie(status, error) = catch_exceptions([&]{ return VerifyLoadedChainstate(chainman, options);});
if (status == node::ChainstateLoadStatus::SUCCESS) {
fLoaded = true;
LogPrintf(" block index %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - load_block_index_start_time));
LogInfo(" block index %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - load_block_index_start_time));
}
}

Expand Down Expand Up @@ -1584,7 +1584,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// requested to kill the GUI during the last operation. If so, exit.
// As the program has not fully started yet, Shutdown() is possibly overkill.
if (ShutdownRequested(node)) {
LogPrintf("Shutdown requested. Exiting.\n");
LogInfo("Shutdown requested. Exiting.\n");
return false;
}

Expand Down Expand Up @@ -1636,7 +1636,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
}
} else {
LogPrintf("Setting NODE_NETWORK on non-prune mode\n");
LogInfo("Setting NODE_NETWORK on non-prune mode\n");
nLocalServices = ServiceFlags(nLocalServices | NODE_NETWORK);
}

Expand Down Expand Up @@ -1703,7 +1703,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Import blocks
ImportBlocks(chainman, vImportFiles);
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
LogPrintf("Stopping after block import\n");
LogInfo("Stopping after block import\n");
if (!(*Assert(node.shutdown))()) {
LogError("Failed to send shutdown signal after finishing block import\n");
}
Expand Down Expand Up @@ -1745,7 +1745,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
int64_t best_block_time{};
{
LOCK(cs_main);
LogPrintf("block tree size = %u\n", chainman.BlockIndex().size());
LogInfo("block tree size = %u\n", chainman.BlockIndex().size());
chain_active_height = chainman.ActiveChain().Height();
best_block_time = chainman.ActiveChain().Tip() ? chainman.ActiveChain().Tip()->GetBlockTime() : chainman.GetParams().GenesisBlock().GetBlockTime();
if (tip_info) {
Expand All @@ -1758,7 +1758,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
tip_info->header_time = chainman.m_best_header->GetBlockTime();
}
}
LogPrintf("nBestHeight = %d\n", chain_active_height);
LogInfo("nBestHeight = %d\n", chain_active_height);
if (node.peerman) node.peerman->SetBestBlock(chain_active_height, std::chrono::seconds{best_block_time});

// Map ports with UPnP or NAT-PMP.
Expand Down Expand Up @@ -1874,11 +1874,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
connOptions.m_specified_outgoing = connect;
}
if (!connOptions.m_specified_outgoing.empty() && !connOptions.vSeedNodes.empty()) {
LogPrintf("-seednode is ignored when -connect is used\n");
LogInfo("-seednode is ignored when -connect is used\n");
}

if (args.IsArgSet("-dnsseed") && args.GetBoolArg("-dnsseed", DEFAULT_DNSSEED) && args.IsArgSet("-proxy")) {
LogPrintf("-dnsseed is ignored when -connect is used and -proxy is specified\n");
LogInfo("-dnsseed is ignored when -connect is used and -proxy is specified\n");
}
}

Expand Down

0 comments on commit 6248ea9

Please sign in to comment.