Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,229 Lines • ▼ Show 20 Lines | bool CheckInputs(const CTransaction &tx, CValidationState &state, | ||||
if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | ||||
return false; | return false; | ||||
} | } | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->reserve(tx.vin.size()); | pvChecks->reserve(tx.vin.size()); | ||||
} | } | ||||
// Skip script verification when connecting blocks under the assumedvalid | // Skip script verification when connecting blocks under the assumevalid | ||||
// block. Assuming the assumedvalid block is valid this is safe because | // block. Assuming the assumevalid block is valid this is safe because | ||||
// block merkle hashes are still computed and checked, of course, if an | // block merkle hashes are still computed and checked, of course, if an | ||||
// assumed valid block is invalid due to false scriptSigs this optimization | // assumed valid block is invalid due to false scriptSigs this optimization | ||||
// would allow an invalid chain to be accepted. | // would allow an invalid chain to be accepted. | ||||
if (!fScriptChecks) { | if (!fScriptChecks) { | ||||
return true; | return true; | ||||
} | } | ||||
// First check if script executions have been cached with the same flags. | // First check if script executions have been cached with the same flags. | ||||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Lines | if (!hashAssumeValid.IsNull()) { | ||||
// effectively caching the result of part of the verification. | // effectively caching the result of part of the verification. | ||||
BlockMap::const_iterator it = mapBlockIndex.find(hashAssumeValid); | BlockMap::const_iterator it = mapBlockIndex.find(hashAssumeValid); | ||||
if (it != mapBlockIndex.end()) { | if (it != mapBlockIndex.end()) { | ||||
if (it->second->GetAncestor(pindex->nHeight) == pindex && | if (it->second->GetAncestor(pindex->nHeight) == pindex && | ||||
pindexBestHeader->GetAncestor(pindex->nHeight) == pindex && | pindexBestHeader->GetAncestor(pindex->nHeight) == pindex && | ||||
pindexBestHeader->nChainWork >= nMinimumChainWork) { | pindexBestHeader->nChainWork >= nMinimumChainWork) { | ||||
// This block is a member of the assumed verified chain and an | // This block is a member of the assumed verified chain and an | ||||
// ancestor of the best header. The equivalent time check | // ancestor of the best header. The equivalent time check | ||||
// discourages hashpower from extorting the network via DOS | // discourages hash power from extorting the network via DOS | ||||
// attack into accepting an invalid block through telling users | // attack into accepting an invalid block through telling users | ||||
// they must manually set assumevalid. Requiring a software | // they must manually set assumevalid. Requiring a software | ||||
// change or burying the invalid block, regardless of the | // change or burying the invalid block, regardless of the | ||||
// setting, makes it hard to hide the implication of the demand. | // setting, makes it hard to hide the implication of the demand. | ||||
// This also avoids having release candidates that are hardly | // This also avoids having release candidates that are hardly | ||||
// doing any signature verification at all in testing without | // doing any signature verification at all in testing without | ||||
// having to artificially set the default assumed verified block | // having to artificially set the default assumed verified block | ||||
// further back. The test against nMinimumChainWork prevents the | // further back. The test against nMinimumChainWork prevents the | ||||
▲ Show 20 Lines • Show All 3,947 Lines • Show Last 20 Lines |