@@ -2208,8 +2208,42 @@ static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
2208
2208
res += warn;
2209
2209
}
2210
2210
2211
+ static void UpdateTipLog (
2212
+ const CCoinsViewCache& coins_tip,
2213
+ const CBlockIndex* tip,
2214
+ const CChainParams& params,
2215
+ const std::string& func_name,
2216
+ const std::string& prefix,
2217
+ const std::string& warning_messages) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
2218
+ {
2219
+
2220
+ AssertLockHeld (::cs_main);
2221
+ LogPrintf (" %s%s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n " ,
2222
+ prefix, func_name,
2223
+ tip->GetBlockHash ().ToString (), tip->nHeight , tip->nVersion ,
2224
+ log (tip->nChainWork .getdouble ()) / log (2.0 ), (unsigned long )tip->nChainTx ,
2225
+ FormatISO8601DateTime (tip->GetBlockTime ()),
2226
+ GuessVerificationProgress (params.TxData (), tip),
2227
+ coins_tip.DynamicMemoryUsage () * (1.0 / (1 << 20 )),
2228
+ coins_tip.GetCacheSize (),
2229
+ !warning_messages.empty () ? strprintf (" warning='%s'" , warning_messages) : " " );
2230
+ }
2231
+
2211
2232
void CChainState::UpdateTip (const CBlockIndex* pindexNew)
2212
2233
{
2234
+ const auto & coins_tip = this ->CoinsTip ();
2235
+
2236
+ // The remainder of the function isn't relevant if we are not acting on
2237
+ // the active chainstate, so return if need be.
2238
+ if (this != &m_chainman.ActiveChainstate ()) {
2239
+ // Only log every so often so that we don't bury log messages at the tip.
2240
+ constexpr int BACKGROUND_LOG_INTERVAL = 2000 ;
2241
+ if (pindexNew->nHeight % BACKGROUND_LOG_INTERVAL == 0 ) {
2242
+ UpdateTipLog (coins_tip, pindexNew, m_params, __func__, " [background validation] " , " " );
2243
+ }
2244
+ return ;
2245
+ }
2246
+
2213
2247
// New best block
2214
2248
if (m_mempool) {
2215
2249
m_mempool->AddTransactionsUpdated (1 );
@@ -2237,12 +2271,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
2237
2271
}
2238
2272
}
2239
2273
}
2240
- LogPrintf (" %s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n " , __func__,
2241
- pindexNew->GetBlockHash ().ToString (), pindexNew->nHeight , pindexNew->nVersion ,
2242
- log (pindexNew->nChainWork .getdouble ())/log (2.0 ), (unsigned long )pindexNew->nChainTx ,
2243
- FormatISO8601DateTime (pindexNew->GetBlockTime ()),
2244
- GuessVerificationProgress (m_params.TxData (), pindexNew), this ->CoinsTip ().DynamicMemoryUsage () * (1.0 / (1 <<20 )), this ->CoinsTip ().GetCacheSize (),
2245
- !warning_messages.empty () ? strprintf (" warning='%s'" , warning_messages.original ) : " " );
2274
+ UpdateTipLog (coins_tip, pindexNew, m_params, __func__, " " , warning_messages.original );
2246
2275
}
2247
2276
2248
2277
/* * Disconnect m_chain's tip.
0 commit comments