Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,105 Lines • ▼ Show 20 Lines | |||||
void PruneAndFlush() { | void PruneAndFlush() { | ||||
CValidationState state; | CValidationState state; | ||||
fCheckForPruning = true; | fCheckForPruning = true; | ||||
const CChainParams &chainparams = Params(); | const CChainParams &chainparams = Params(); | ||||
FlushStateToDisk(chainparams, state, FlushStateMode::NONE); | FlushStateToDisk(chainparams, state, FlushStateMode::NONE); | ||||
} | } | ||||
static void DoWarning(const std::string &strWarning) { | |||||
static bool fWarned = false; | |||||
SetMiscWarning(strWarning); | |||||
if (!fWarned) { | |||||
AlertNotify(strWarning); | |||||
fWarned = true; | |||||
} | |||||
} | |||||
/** | /** | ||||
* Update chainActive and related internal data structures when adding a new | * Update chainActive and related internal data structures when adding a new | ||||
* block to the chain tip. | * block to the chain tip. | ||||
*/ | */ | ||||
static void UpdateTip(const Config &config, CBlockIndex *pindexNew) { | static void UpdateTip(const Config &config, CBlockIndex *pindexNew) { | ||||
const Consensus::Params &consensusParams = | const Consensus::Params &consensusParams = | ||||
config.GetChainParams().GetConsensus(); | config.GetChainParams().GetConsensus(); | ||||
chainActive.SetTip(pindexNew); | chainActive.SetTip(pindexNew); | ||||
// New best block | // New best block | ||||
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; | |||||
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) { | if (nUpgraded > 100 / 2) { | ||||
std::string strWarning = | std::string strWarning = | ||||
_("Warning: Unknown block versions being mined! It's possible " | _("Warning: Unknown block versions being mined! It's possible " | ||||
"unknown rules are in effect"); | "unknown rules are in effect"); | ||||
// notify GetWarnings(), called by Qt and the JSON-RPC code to warn | // notify GetWarnings(), called by Qt and the JSON-RPC code to warn | ||||
// the user: | // the user: | ||||
SetMiscWarning(strWarning); | DoWarning(strWarning); | ||||
if (!fWarned) { | |||||
AlertNotify(strWarning); | |||||
fWarned = true; | |||||
} | |||||
} | } | ||||
} | } | ||||
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, | ||||
▲ Show 20 Lines • Show All 3,469 Lines • Show Last 20 Lines |