src/validation.cpp
void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
    chainActive.SetTip(pindexNew);

    // New best block
    mempool.AddTransactionsUpdated(1);

    LogPrintf("%s: new best=%s  height=%d bits=%d log2_work=%.8g  tx=%lu  date=%s progress=%f  cache=%.1fMiB(%utxo)\n", __func__,
      chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nBits,
      log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
      DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
      Checkpoints::GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());

    {
        LOCK(g_best_block_mutex);
        g_best_block = pindexNew->GetBlockHash();
        g_best_block_cv.notify_all();
    }

    // Check the version of the last 100 blocks to see if we need to upgrade:
    static bool fWarned = false;
    if (!IsInitialBlockDownload() && !fWarned)
    {
        int nUpgraded = 0;
        const CBlockIndex* pindex = chainActive.Tip();
        for (int i = 0; i < 100 && pindex != nullptr; i++)
        {
            if (pindex->nVersion > CBlock::CURRENT_VERSION)
                ++nUpgraded;
            pindex = pindex->pprev;
        }
        if (nUpgraded > 0)
            LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION);
        if (nUpgraded > 100/2)
        {
            // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
            strMiscWarning = _("Warning: This version is obsolete, upgrade required!");
            CAlert::Notify(strMiscWarning, true);
            fWarned = true;
        }
    }
}
/** Update chainActive and related internal data structures. */
Update chainActive and related internal data structures.
Update chainActive and related internal data structures .
void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
    chainActive.SetTip(pindexNew);
    mempool.AddTransactionsUpdated(1);
    LogPrintf("%s: new best=%s  height=%d bits=%d log2_work=%.8g  tx=%lu  date=%s progress=%f  cache=%.1fMiB(%utxo)\n", __func__,
      chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nBits,
      log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
      DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
      Checkpoints::GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
    {
        LOCK(g_best_block_mutex);
        g_best_block = pindexNew->GetBlockHash();
        g_best_block_cv.notify_all();
    }
    static bool fWarned = false;
    if (!IsInitialBlockDownload() && !fWarned)
    {
        int nUpgraded = 0;
        const CBlockIndex* pindex = chainActive.Tip();
        for (int i = 0; i < 100 && pindex != nullptr; i++)
        {
            if (pindex->nVersion > CBlock::CURRENT_VERSION)
                ++nUpgraded;
            pindex = pindex->pprev;
        }
        if (nUpgraded > 0)
            LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION);
        if (nUpgraded > 100/2)
        {
            strMiscWarning = _("Warning: This version is obsolete, upgrade required!");
            CAlert::Notify(strMiscWarning, true);
            fWarned = true;
        }
    }
}
void static UpdateTip ( CBlockIndex * pindexNew , const CChainParams & chainParams ) { chainActive . SetTip ( pindexNew ) ; mempool . AddTransactionsUpdated ( 1 ) ; LogPrintf ( " \n " , __func__ , chainActive . Tip ( ) -> GetBlockHash ( ) . ToString ( ) , chainActive . Height ( ) , chainActive . Tip ( ) -> nBits , log ( chainActive . Tip ( ) -> nChainWork . getdouble ( ) ) / log ( 2.0 ) , ( unsigned long ) chainActive . Tip ( ) -> nChainTx , DateTimeStrFormat ( " " , chainActive . Tip ( ) -> GetBlockTime ( ) ) , Checkpoints :: GuessVerificationProgress ( chainParams . TxData ( ) , chainActive . Tip ( ) ) , pcoinsTip -> DynamicMemoryUsage ( ) * ( 1.0 / ( 1 << 20 ) ) , pcoinsTip -> GetCacheSize ( ) ) ; { LOCK ( g_best_block_mutex ) ; g_best_block = pindexNew -> GetBlockHash ( ) ; g_best_block_cv . notify_all ( ) ; } static bool fWarned = false ; if ( ! IsInitialBlockDownload ( ) && ! fWarned ) { int nUpgraded = 0 ; const CBlockIndex * pindex = chainActive . Tip ( ) ; for ( int i = 0 ; i < 100 && pindex != nullptr ; i ++ ) { if ( pindex -> nVersion > CBlock :: CURRENT_VERSION ) ++ nUpgraded ; pindex = pindex -> pprev ; } if ( nUpgraded > 0 ) LogPrintf ( " \n " , nUpgraded , ( int ) CBlock :: CURRENT_VERSION ) ; if ( nUpgraded > 100 / 2 ) { strMiscWarning = _ ( " " ) ; CAlert :: Notify ( strMiscWarning , true ) ; fWarned = true ; } } }
Update chainActive and related internal data structures.
Update chainActive and related internal data structures .
// New best block // Check the version of the last 100 blocks to see if we need to upgrade: // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user: