Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,135 Lines • ▼ Show 20 Lines | static void UpdateTip(const Config &config, CBlockIndex *pindexNew) { | ||||
g_mempool.AddTransactionsUpdated(1); | g_mempool.AddTransactionsUpdated(1); | ||||
{ | { | ||||
LOCK(g_best_block_mutex); | LOCK(g_best_block_mutex); | ||||
g_best_block = pindexNew->GetBlockHash(); | g_best_block = pindexNew->GetBlockHash(); | ||||
g_best_block_cv.notify_all(); | g_best_block_cv.notify_all(); | ||||
} | } | ||||
static bool fWarned = false; | |||||
nakihito: Although it was already mentioned by @deadalnix about the below block of code, if there's a… | |||||
std::vector<std::string> warningMessages; | std::vector<std::string> warningMessages; | ||||
if (!IsInitialBlockDownload()) { | if (!IsInitialBlockDownload()) { | ||||
int nUpgraded = 0; | int nUpgraded = 0; | ||||
const CBlockIndex *pindex = chainActive.Tip(); | const CBlockIndex *pindex = chainActive.Tip(); | ||||
// Check the version of the last 100 blocks to see if we need to | // Check the version of the last 100 blocks to see if we need to | ||||
// upgrade: | // upgrade: | ||||
for (int i = 0; i < 100 && pindex != nullptr; i++) { | for (int i = 0; i < 100 && pindex != nullptr; i++) { | ||||
int32_t nExpectedVersion = | int32_t nExpectedVersion = | ||||
ComputeBlockVersion(pindex->pprev, consensusParams); | ComputeBlockVersion(pindex->pprev, consensusParams); | ||||
if (pindex->nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION && | if (pindex->nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION && | ||||
(pindex->nVersion & ~nExpectedVersion) != 0) { | (pindex->nVersion & ~nExpectedVersion) != 0) { | ||||
++nUpgraded; | ++nUpgraded; | ||||
} | } | ||||
pindex = pindex->pprev; | pindex = pindex->pprev; | ||||
} | } | ||||
if (nUpgraded > 0) { | if (nUpgraded > 0) { | ||||
warningMessages.push_back(strprintf( | warningMessages.push_back(strprintf( | ||||
"%d of last 100 blocks have unexpected version", nUpgraded)); | "%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"); | |||||
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn | |||||
// the user: | |||||
SetMiscWarning(strWarning); | |||||
if (!fWarned) { | |||||
AlertNotify(strWarning); | |||||
fWarned = true; | |||||
} | |||||
} | |||||
deadalnixUnsubmitted Done Inline ActionsThis code doesn't match what is in the PR. This usually indicate that some previous backport is missing. If that's the case, this previous backport will become harder to backport. Unless there is a good reason to not do it, backporting this previous PR. deadalnix: This code doesn't match what is in the PR. This usually indicate that some previous backport is… | |||||
} | } | ||||
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu " | LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu " | ||||
"date='%s' progress=%f cache=%.1fMiB(%utxo)", | "date='%s' progress=%f cache=%.1fMiB(%utxo)", | ||||
__func__, chainActive.Tip()->GetBlockHash().ToString(), | __func__, chainActive.Tip()->GetBlockHash().ToString(), | ||||
chainActive.Height(), chainActive.Tip()->nVersion, | chainActive.Height(), chainActive.Tip()->nVersion, | ||||
log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0), | log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0), | ||||
(unsigned long)chainActive.Tip()->nChainTx, | (unsigned long)chainActive.Tip()->nChainTx, | ||||
FormatISO8601DateTime(chainActive.Tip()->GetBlockTime()), | FormatISO8601DateTime(chainActive.Tip()->GetBlockTime()), | ||||
▲ Show 20 Lines • Show All 3,467 Lines • Show Last 20 Lines |
Although it was already mentioned by @deadalnix about the below block of code, if there's a left over unused variable after a backport, it probably means there was at least one missing backport between us and this PR that would fix the issue.