Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,886 Lines • ▼ Show 20 Lines | bool CChainState::ConnectBlock(const CBlock &block, CValidationState &state, | ||||
int64_t nTime2 = GetTimeMicros(); | int64_t nTime2 = GetTimeMicros(); | ||||
nTimeForks += nTime2 - nTime1; | nTimeForks += nTime2 - nTime1; | ||||
LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n", | LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
MILLI * (nTime2 - nTime1), nTimeForks * MICRO, | MILLI * (nTime2 - nTime1), nTimeForks * MICRO, | ||||
nTimeForks * MILLI / nBlocksTotal); | nTimeForks * MILLI / nBlocksTotal); | ||||
CBlockUndo blockundo; | CBlockUndo blockundo; | ||||
CCheckQueueControl<CScriptCheck> control(fScriptChecks ? &scriptcheckqueue | |||||
: nullptr); | |||||
std::vector<int> prevheights; | std::vector<int> prevheights; | ||||
Amount nFees = Amount::zero(); | Amount nFees = Amount::zero(); | ||||
int nInputs = 0; | int nInputs = 0; | ||||
// Sigops counting. We need to do it again because of P2SH. | // Sigops counting. We need to do it again because of P2SH. | ||||
uint64_t nSigOpsCount = 0; | uint64_t nSigOpsCount = 0; | ||||
const uint64_t currentBlockSize = | const uint64_t currentBlockSize = | ||||
::GetSerializeSize(block, PROTOCOL_VERSION); | ::GetSerializeSize(block, PROTOCOL_VERSION); | ||||
const uint64_t nMaxSigOpsCount = GetMaxBlockSigOpsCount(currentBlockSize); | const uint64_t nMaxSigOpsCount = GetMaxBlockSigOpsCount(currentBlockSize); | ||||
// Limit the total executed signature operations in the block, a consensus | // Limit the total executed signature operations in the block, a consensus | ||||
// rule. Tracking during the CPU-consuming part (validation of uncached | // rule. Tracking during the CPU-consuming part (validation of uncached | ||||
// inputs) is per-input atomic and validation in each thread stops very | // inputs) is per-input atomic and validation in each thread stops very | ||||
// quickly after the limit is exceeded, so an adversary cannot cause us to | // quickly after the limit is exceeded, so an adversary cannot cause us to | ||||
// exceed the limit by much at all. | // exceed the limit by much at all. | ||||
CheckInputsLimiter nSigChecksBlockLimiter( | CheckInputsLimiter nSigChecksBlockLimiter( | ||||
GetMaxBlockSigChecksCount(options.getExcessiveBlockSize())); | GetMaxBlockSigChecksCount(options.getExcessiveBlockSize())); | ||||
blockundo.vtxundo.reserve(block.vtx.size() - 1); | blockundo.vtxundo.reserve(block.vtx.size() - 1); | ||||
CCheckQueueControl<CScriptCheck> control(fScriptChecks ? &scriptcheckqueue | |||||
: nullptr); | |||||
// Add all outputs | // Add all outputs | ||||
try { | try { | ||||
for (const auto &ptx : block.vtx) { | for (const auto &ptx : block.vtx) { | ||||
AddCoins(view, *ptx, pindex->nHeight); | AddCoins(view, *ptx, pindex->nHeight); | ||||
} | } | ||||
} catch (const std::logic_error &e) { | } catch (const std::logic_error &e) { | ||||
// This error will be thrown from AddCoin if we try to connect a block | // This error will be thrown from AddCoin if we try to connect a block | ||||
// containing duplicate transactions. Such a thing should normally be | // containing duplicate transactions. Such a thing should normally be | ||||
▲ Show 20 Lines • Show All 3,929 Lines • Show Last 20 Lines |