aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2019-01-29 13:03:53 +0000
committerGregory Sanders <gsanders87@gmail.com>2019-01-29 13:03:53 +0000
commitec30a79f1c430cc7fbda37e5d747b0b31b262fa5 (patch)
tree016cff9c3a04977f9215c975476c6f81d4110049 /src/validation.cpp
parentd6e700e40f861ddd6743f4d13f0d6f6bc19093c2 (diff)
downloadbitcoin-ec30a79f1c430cc7fbda37e5d747b0b31b262fa5.tar.xz
Fix UB with bench on genesis block
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 6a26bf9baa..70f233f464 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1834,6 +1834,8 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
uint256 hashPrevBlock = pindex->pprev == nullptr ? uint256() : pindex->pprev->GetBlockHash();
assert(hashPrevBlock == view.GetBestBlock());
+ nBlocksTotal++;
+
// Special case for the genesis block, skipping connection of its transactions
// (its coinbase is unspendable)
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
@@ -1842,8 +1844,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
return true;
}
- nBlocksTotal++;
-
bool fScriptChecks = true;
if (!hashAssumeValid.IsNull()) {
// We've been configured with the hash of a block which has been externally verified to have a valid history.
@@ -2445,6 +2445,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
return error("%s: ConnectBlock %s failed, %s", __func__, pindexNew->GetBlockHash().ToString(), FormatStateMessage(state));
}
nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2;
+ assert(nBlocksTotal > 0);
LogPrint(BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime3 - nTime2) * MILLI, nTimeConnectTotal * MICRO, nTimeConnectTotal * MILLI / nBlocksTotal);
bool flushed = view.Flush();
assert(flushed);