Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,112 Lines • ▼ Show 20 Lines | if (!fRequested) { | ||||
// low-work blocks on a fake chain that we would never | // low-work blocks on a fake chain that we would never | ||||
// request; don't process these. | // request; don't process these. | ||||
if (pindex->nChainWork < nMinimumChainWork) { | if (pindex->nChainWork < nMinimumChainWork) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
const Consensus::Params &consensusParams = chainparams.GetConsensus(); | |||||
if (!CheckBlock(block, state, chainparams.GetConsensus(), | if (!CheckBlock(block, state, consensusParams, | ||||
BlockValidationOptions(config)) || | BlockValidationOptions(config)) || | ||||
!ContextualCheckBlock(block, state, chainparams.GetConsensus(), | !ContextualCheckBlock(block, state, consensusParams, pindex->pprev)) { | ||||
pindex->pprev)) { | |||||
if (state.IsInvalid() && !state.CorruptionPossible()) { | if (state.IsInvalid() && !state.CorruptionPossible()) { | ||||
pindex->nStatus = pindex->nStatus.withFailed(); | pindex->nStatus = pindex->nStatus.withFailed(); | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
} | } | ||||
return error("%s: %s (block %s)", __func__, FormatStateMessage(state), | return error("%s: %s (block %s)", __func__, FormatStateMessage(state), | ||||
block.GetHash().ToString()); | block.GetHash().ToString()); | ||||
} | } | ||||
Show All 32 Lines | try { | ||||
__func__)); | __func__)); | ||||
return false; | return false; | ||||
} | } | ||||
ReceivedBlockTransactions(block, pindex, blockPos); | ReceivedBlockTransactions(block, pindex, blockPos); | ||||
} catch (const std::runtime_error &e) { | } catch (const std::runtime_error &e) { | ||||
return AbortNode(state, std::string("System error: ") + e.what()); | return AbortNode(state, std::string("System error: ") + e.what()); | ||||
} | } | ||||
FlushStateToDisk(config.GetChainParams(), state, FlushStateMode::NONE); | FlushStateToDisk(chainparams, state, FlushStateMode::NONE); | ||||
CheckBlockIndex(chainparams.GetConsensus()); | CheckBlockIndex(consensusParams); | ||||
return true; | return true; | ||||
} | } | ||||
bool ProcessNewBlock(const Config &config, | bool ProcessNewBlock(const Config &config, | ||||
const std::shared_ptr<const CBlock> pblock, | const std::shared_ptr<const CBlock> pblock, | ||||
bool fForceProcessing, bool *fNewBlock) { | bool fForceProcessing, bool *fNewBlock) { | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
▲ Show 20 Lines • Show All 1,587 Lines • Show Last 20 Lines |