@@ -2433,7 +2433,7 @@ static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
24332433}
24342434
24352435/* * Check warning conditions and do some notifications on new chain tip set. */
2436- static void UpdateTip (CTxMemPool& mempool, const CBlockIndex* pindexNew, const CChainParams& chainParams)
2436+ static void UpdateTip (CTxMemPool& mempool, const CBlockIndex* pindexNew, const CChainParams& chainParams, CChainState& active_chainstate )
24372437 EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
24382438{
24392439 // New best block
@@ -2446,7 +2446,8 @@ static void UpdateTip(CTxMemPool& mempool, const CBlockIndex* pindexNew, const C
24462446 }
24472447
24482448 bilingual_str warning_messages;
2449- if (!::ChainstateActive ().IsInitialBlockDownload ()) {
2449+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
2450+ if (!active_chainstate.IsInitialBlockDownload ()) {
24502451 const CBlockIndex* pindex = pindexNew;
24512452 for (int bit = 0 ; bit < VERSIONBITS_NUM_BITS; bit++) {
24522453 WarningBitsConditionChecker checker (bit);
@@ -2461,11 +2462,12 @@ static void UpdateTip(CTxMemPool& mempool, const CBlockIndex* pindexNew, const C
24612462 }
24622463 }
24632464 }
2465+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
24642466 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__,
24652467 pindexNew->GetBlockHash ().ToString (), pindexNew->nHeight , pindexNew->nVersion ,
24662468 log (pindexNew->nChainWork .getdouble ())/log (2.0 ), (unsigned long )pindexNew->nChainTx ,
24672469 FormatISO8601DateTime (pindexNew->GetBlockTime ()),
2468- GuessVerificationProgress (chainParams.TxData (), pindexNew), :: ChainstateActive () .CoinsTip ().DynamicMemoryUsage () * (1.0 / (1 <<20 )), :: ChainstateActive () .CoinsTip ().GetCacheSize (),
2470+ GuessVerificationProgress (chainParams.TxData (), pindexNew), active_chainstate .CoinsTip ().DynamicMemoryUsage () * (1.0 / (1 <<20 )), active_chainstate .CoinsTip ().GetCacheSize (),
24692471 !warning_messages.empty () ? strprintf (" warning='%s'" , warning_messages.original ) : " " );
24702472}
24712473
@@ -2521,7 +2523,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams&
25212523
25222524 m_chain.SetTip (pindexDelete->pprev );
25232525
2524- UpdateTip (m_mempool, pindexDelete->pprev , chainparams);
2526+ UpdateTip (m_mempool, pindexDelete->pprev , chainparams, * this );
25252527 // Let wallets know transactions went from 1-confirmed to
25262528 // 0-confirmed or conflicted:
25272529 GetMainSignals ().BlockDisconnected (pblock, pindexDelete);
@@ -2629,7 +2631,7 @@ bool CChainState::ConnectTip(BlockValidationState& state, const CChainParams& ch
26292631 disconnectpool.removeForBlock (blockConnecting.vtx );
26302632 // Update m_chain & related variables.
26312633 m_chain.SetTip (pindexNew);
2632- UpdateTip (m_mempool, pindexNew, chainparams);
2634+ UpdateTip (m_mempool, pindexNew, chainparams, * this );
26332635
26342636 int64_t nTime6 = GetTimeMicros (); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
26352637 LogPrint (BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime6 - nTime5) * MILLI, nTimePostConnect * MICRO, nTimePostConnect * MILLI / nBlocksTotal);
0 commit comments