Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,630 Lines • ▼ Show 20 Lines | if (!CheckBlock(block, state, consensusParams, | ||||
state.ToString()); | state.ToString()); | ||||
} | } | ||||
// Verify that the view's current state corresponds to the previous block | // Verify that the view's current state corresponds to the previous block | ||||
BlockHash hashPrevBlock = | BlockHash hashPrevBlock = | ||||
pindex->pprev == nullptr ? BlockHash() : pindex->pprev->GetBlockHash(); | pindex->pprev == nullptr ? BlockHash() : pindex->pprev->GetBlockHash(); | ||||
assert(hashPrevBlock == view.GetBestBlock()); | assert(hashPrevBlock == view.GetBestBlock()); | ||||
nBlocksTotal++; | |||||
// Special case for the genesis block, skipping connection of its | // Special case for the genesis block, skipping connection of its | ||||
// transactions (its coinbase is unspendable) | // transactions (its coinbase is unspendable) | ||||
if (block.GetHash() == consensusParams.hashGenesisBlock) { | if (block.GetHash() == consensusParams.hashGenesisBlock) { | ||||
if (!fJustCheck) { | if (!fJustCheck) { | ||||
view.SetBestBlock(pindex->GetBlockHash()); | view.SetBestBlock(pindex->GetBlockHash()); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
nBlocksTotal++; | |||||
bool fScriptChecks = true; | bool fScriptChecks = true; | ||||
if (!hashAssumeValid.IsNull()) { | if (!hashAssumeValid.IsNull()) { | ||||
// We've been configured with the hash of a block which has been | // We've been configured with the hash of a block which has been | ||||
// externally verified to have a valid history. A suitable default value | // externally verified to have a valid history. A suitable default value | ||||
// is included with the software and updated from time to time. Because | // is included with the software and updated from time to time. Because | ||||
// validity relative to a piece of software is an objective fact these | // validity relative to a piece of software is an objective fact these | ||||
// defaults can be easily reviewed. This setting doesn't force the | // defaults can be easily reviewed. This setting doesn't force the | ||||
// selection of any particular chain but makes validating some faster by | // selection of any particular chain but makes validating some faster by | ||||
▲ Show 20 Lines • Show All 899 Lines • ▼ Show 20 Lines | LogPrint(BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n", | ||||
if (pindexToFinalize && !MarkBlockAsFinal(state, pindexToFinalize)) { | if (pindexToFinalize && !MarkBlockAsFinal(state, pindexToFinalize)) { | ||||
return error("ConnectTip(): MarkBlockAsFinal %s failed (%s)", | return error("ConnectTip(): MarkBlockAsFinal %s failed (%s)", | ||||
pindexNew->GetBlockHash().ToString(), | pindexNew->GetBlockHash().ToString(), | ||||
state.ToString()); | state.ToString()); | ||||
} | } | ||||
nTime3 = GetTimeMicros(); | nTime3 = GetTimeMicros(); | ||||
nTimeConnectTotal += nTime3 - nTime2; | nTimeConnectTotal += nTime3 - nTime2; | ||||
assert(nBlocksTotal > 0); | |||||
LogPrint(BCLog::BENCH, | LogPrint(BCLog::BENCH, | ||||
" - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n", | " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
(nTime3 - nTime2) * MILLI, nTimeConnectTotal * MICRO, | (nTime3 - nTime2) * MILLI, nTimeConnectTotal * MICRO, | ||||
nTimeConnectTotal * MILLI / nBlocksTotal); | nTimeConnectTotal * MILLI / nBlocksTotal); | ||||
bool flushed = view.Flush(); | bool flushed = view.Flush(); | ||||
assert(flushed); | assert(flushed); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,465 Lines • Show Last 20 Lines |