Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,119 Lines • ▼ Show 20 Lines | bool ProcessNewBlock(const Config &config, | ||||
if (!g_chainstate.ActivateBestChain(config, state, pblock)) { | if (!g_chainstate.ActivateBestChain(config, state, pblock)) { | ||||
return error("%s: ActivateBestChain failed (%s)", __func__, | return error("%s: ActivateBestChain failed (%s)", __func__, | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool TestBlockValidity(const Config &config, CValidationState &state, | bool TestBlockValidity(CValidationState &state, const CChainParams ¶ms, | ||||
const CBlock &block, CBlockIndex *pindexPrev, | const CBlock &block, CBlockIndex *pindexPrev, | ||||
BlockValidationOptions validationOptions) { | BlockValidationOptions validationOptions) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
assert(pindexPrev && pindexPrev == chainActive.Tip()); | assert(pindexPrev && pindexPrev == chainActive.Tip()); | ||||
CCoinsViewCache viewNew(pcoinsTip.get()); | CCoinsViewCache viewNew(pcoinsTip.get()); | ||||
uint256 block_hash(block.GetHash()); | uint256 block_hash(block.GetHash()); | ||||
CBlockIndex indexDummy(block); | CBlockIndex indexDummy(block); | ||||
indexDummy.pprev = pindexPrev; | indexDummy.pprev = pindexPrev; | ||||
indexDummy.nHeight = pindexPrev->nHeight + 1; | indexDummy.nHeight = pindexPrev->nHeight + 1; | ||||
indexDummy.phashBlock = &block_hash; | indexDummy.phashBlock = &block_hash; | ||||
// NOTE: CheckBlockHeader is called by CheckBlock | // NOTE: CheckBlockHeader is called by CheckBlock | ||||
if (!ContextualCheckBlockHeader(config.GetChainParams(), block, state, | if (!ContextualCheckBlockHeader(params, block, state, pindexPrev, | ||||
pindexPrev, GetAdjustedTime())) { | GetAdjustedTime())) { | ||||
return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, | return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
if (!CheckBlock(block, state, config.GetChainParams().GetConsensus(), | if (!CheckBlock(block, state, params.GetConsensus(), validationOptions)) { | ||||
validationOptions)) { | |||||
return error("%s: Consensus::CheckBlock: %s", __func__, | return error("%s: Consensus::CheckBlock: %s", __func__, | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
if (!ContextualCheckBlock( | if (!ContextualCheckBlock(block, state, params.GetConsensus(), | ||||
block, state, config.GetChainParams().GetConsensus(), pindexPrev)) { | pindexPrev)) { | ||||
return error("%s: Consensus::ContextualCheckBlock: %s", __func__, | return error("%s: Consensus::ContextualCheckBlock: %s", __func__, | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
} | } | ||||
if (!g_chainstate.ConnectBlock(block, state, &indexDummy, viewNew, | if (!g_chainstate.ConnectBlock(block, state, &indexDummy, viewNew, params, | ||||
config.GetChainParams(), validationOptions, | validationOptions, true)) { | ||||
true)) { | |||||
return false; | return false; | ||||
} | } | ||||
assert(state.IsValid()); | assert(state.IsValid()); | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 1,552 Lines • Show Last 20 Lines |