Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,026 Lines • ▼ Show 20 Lines | void CChainState::PruneAndFlush() { | ||||
fCheckForPruning = true; | fCheckForPruning = true; | ||||
const CChainParams &chainparams = Params(); | const CChainParams &chainparams = Params(); | ||||
if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::NONE)) { | if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::NONE)) { | ||||
LogPrintf("%s: failed to flush state (%s)\n", __func__, | LogPrintf("%s: failed to flush state (%s)\n", __func__, | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
} | } | ||||
static void LogUpgradeActivation(const std::string upgradeName) { | |||||
Fabien: Pass by reference | |||||
LogPrintf("Upgrade activated: '%s'. The next block will abide by the new " | |||||
"rules.\n", | |||||
upgradeName); | |||||
} | |||||
/** Check warning conditions and do some notifications on new chain tip set. */ | /** Check warning conditions and do some notifications on new chain tip set. */ | ||||
static void UpdateTip(const CChainParams ¶ms, CBlockIndex *pindexNew) { | static void UpdateTip(const CChainParams ¶ms, CBlockIndex *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(); | ||||
} | } | ||||
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%ld " | LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%ld " | ||||
"date='%s' progress=%f cache=%.1fMiB(%utxo)\n", | "date='%s' progress=%f cache=%.1fMiB(%utxo)\n", | ||||
__func__, pindexNew->GetBlockHash().ToString(), | __func__, pindexNew->GetBlockHash().ToString(), | ||||
pindexNew->nHeight, pindexNew->nVersion, | pindexNew->nHeight, pindexNew->nVersion, | ||||
log(pindexNew->nChainWork.getdouble()) / log(2.0), | log(pindexNew->nChainWork.getdouble()) / log(2.0), | ||||
pindexNew->GetChainTxCount(), | pindexNew->GetChainTxCount(), | ||||
FormatISO8601DateTime(pindexNew->GetBlockTime()), | FormatISO8601DateTime(pindexNew->GetBlockTime()), | ||||
GuessVerificationProgress(params.TxData(), pindexNew), | GuessVerificationProgress(params.TxData(), pindexNew), | ||||
pcoinsTip->DynamicMemoryUsage() * (1.0 / (1 << 20)), | pcoinsTip->DynamicMemoryUsage() * (1.0 / (1 << 20)), | ||||
pcoinsTip->GetCacheSize()); | pcoinsTip->GetCacheSize()); | ||||
// Log upgrade activations | |||||
const Consensus::Params &consensusParams = params.GetConsensus(); | |||||
if (!IsUAHFenabled(consensusParams, pindexNew->pprev) && | |||||
IsUAHFenabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("UAHF"); | |||||
} | |||||
if (!IsDAAEnabled(consensusParams, pindexNew->pprev) && | |||||
IsDAAEnabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("DAA (2017)"); | |||||
} | |||||
if (!IsMagneticAnomalyEnabled(consensusParams, pindexNew->pprev) && | |||||
IsMagneticAnomalyEnabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("Magnetic Anomaly"); | |||||
} | |||||
if (!IsGravitonEnabled(consensusParams, pindexNew->pprev) && | |||||
IsGravitonEnabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("Graviton"); | |||||
} | |||||
if (!IsPhononEnabled(consensusParams, pindexNew->pprev) && | |||||
IsPhononEnabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("Phonon"); | |||||
} | |||||
if (!IsAxionEnabled(consensusParams, pindexNew->pprev) && | |||||
IsAxionEnabled(consensusParams, pindexNew)) { | |||||
LogUpgradeActivation("Axion"); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Disconnect m_chain's tip. | * Disconnect m_chain's tip. | ||||
* After calling, the mempool will be in an inconsistent state, with | * After calling, the mempool will be in an inconsistent state, with | ||||
* transactions from disconnected blocks being added to disconnectpool. You | * transactions from disconnected blocks being added to disconnectpool. You | ||||
* should make the mempool consistent again by calling updateMempoolForReorg. | * should make the mempool consistent again by calling updateMempoolForReorg. | ||||
* with cs_main held. | * with cs_main held. | ||||
▲ Show 20 Lines • Show All 3,581 Lines • Show Last 20 Lines |
Pass by reference