src/validation.cpp
/** 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);
    cvBlockChange.notify_all();
    static bool fWarned = false;
    std::vector<std::string> warningMessages;
    if (!IsInitialBlockDownload())
    {
        int nUpgraded = 0;
        const CBlockIndex* pindex = chainActive.Tip();
        for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
			if (bit == 8 || bit == 28)
				continue;
            WarningBitsConditionChecker checker(bit);
            ThresholdState state = checker.GetStateFor(pindex, chainParams.GetConsensus(), warningcache[bit]);
            if (state == THRESHOLD_ACTIVE || state == THRESHOLD_LOCKED_IN) {
                if (state == THRESHOLD_ACTIVE) {
                    std::string strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
                    SetMiscWarning(strWarning);
                    if (!fWarned) {
                        CAlert::Notify(strWarning);
                        fWarned = true;
                    }
                } else {
                    warningMessages.push_back(strprintf("unknown new rules are about to activate (versionbit %i)", bit));
                }
            }
        }
        for (int i = 0; i < 100 && pindex != NULL; i++)
        {
			const int32_t nExpectedVersion = ComputeBlockVersion(pindex->pprev, chainParams.GetConsensus());
			if (pindex->GetBaseVersion() > VERSIONBITS_LAST_OLD_BLOCK_VERSION && (pindex->GetBaseVersion() & ~nExpectedVersion) != 0)
                ++nUpgraded;
            pindex = pindex->pprev;
        }
        if (nUpgraded > 0)
            warningMessages.push_back(strprintf("%d of last 100 blocks have unexpected version", nUpgraded));
        if (nUpgraded > 100/2)
        {
            std::string strWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
            SetMiscWarning(strWarning);
            if (!fWarned) {
                CAlert::Notify(strWarning);
                fWarned = true;
            }
        }
    }
	if (fDebug) {
		LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)", __func__,
			chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->nVersion,
			log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
			DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
			GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1 << 20)), pcoinsTip->GetCacheSize());
		if (!warningMessages.empty())
			LogPrintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
		LogPrintf("\n");
	}
}
void static UpdateTip ( CBlockIndex * pindexNew , const CChainParams & chainParams ) { chainActive . SetTip ( pindexNew ) ; mempool . AddTransactionsUpdated ( 1 ) ; cvBlockChange . notify_all ( ) ; static bool fWarned = false ; std :: vector < std :: string > warningMessages ; if ( ! IsInitialBlockDownload ( ) ) { int nUpgraded = 0 ; const CBlockIndex * pindex = chainActive . Tip ( ) ; for ( int bit = 0 ; bit < VERSIONBITS_NUM_BITS ; bit ++ ) { if ( bit == 8 || bit == 28 ) continue ; WarningBitsConditionChecker checker ( bit ) ; ThresholdState state = checker . GetStateFor ( pindex , chainParams . GetConsensus ( ) , warningcache [ bit ] ) ; if ( state == THRESHOLD_ACTIVE || state == THRESHOLD_LOCKED_IN ) { if ( state == THRESHOLD_ACTIVE ) { std :: string strWarning = strprintf ( _ ( " " ) , bit ) ; SetMiscWarning ( strWarning ) ; if ( ! fWarned ) { CAlert :: Notify ( strWarning ) ; fWarned = true ; } } else { warningMessages . push_back ( strprintf ( " " , bit ) ) ; } } } for ( int i = 0 ; i < 100 && pindex != NULL ; i ++ ) { const int32_t nExpectedVersion = ComputeBlockVersion ( pindex -> pprev , chainParams . GetConsensus ( ) ) ; if ( pindex -> GetBaseVersion ( ) > VERSIONBITS_LAST_OLD_BLOCK_VERSION && ( pindex -> GetBaseVersion ( ) & ~ nExpectedVersion ) != 0 ) ++ nUpgraded ; pindex = pindex -> pprev ; } if ( nUpgraded > 0 ) warningMessages . push_back ( strprintf ( " " , nUpgraded ) ) ; if ( nUpgraded > 100 / 2 ) { std :: string strWarning = _ ( " " ) ; SetMiscWarning ( strWarning ) ; if ( ! fWarned ) { CAlert :: Notify ( strWarning ) ; fWarned = true ; } } } if ( fDebug ) { LogPrintf ( " " , __func__ , chainActive . Tip ( ) -> GetBlockHash ( ) . ToString ( ) , chainActive . Height ( ) , chainActive . Tip ( ) -> nVersion , log ( chainActive . Tip ( ) -> nChainWork . getdouble ( ) ) / log ( 2.0 ) , ( unsigned long ) chainActive . Tip ( ) -> nChainTx , DateTimeStrFormat ( " " , chainActive . Tip ( ) -> GetBlockTime ( ) ) , GuessVerificationProgress ( chainParams . TxData ( ) , chainActive . Tip ( ) ) , pcoinsTip -> DynamicMemoryUsage ( ) * ( 1.0 / ( 1 << 20 ) ) , pcoinsTip -> GetCacheSize ( ) ) ; if ( ! warningMessages . empty ( ) ) LogPrintf ( " " , boost :: algorithm :: join ( warningMessages , " " ) ) ; LogPrintf ( " \n " ) ; } }
Update chainActive and related internal data structures.
Update chainActive and related internal data structures .
// New best block // MARTKIST, skip auxpow bit 8 or dummy bit 28 // Check the version of the last 100 blocks to see if we need to upgrade: // MARTKIST getbaseversion // notify GetWarnings(), called by Qt and the JSON-RPC code to warn the user: