51
51
# error "Bitcoin cannot be compiled without assertions."
52
52
#endif
53
53
54
+ #define MICRO 0.000001
55
+ #define MILLI 0.001
56
+
54
57
/* *
55
58
* Global state
56
59
*/
@@ -1552,7 +1555,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1552
1555
}
1553
1556
1554
1557
int64_t nTime1 = GetTimeMicros (); nTimeCheck += nTime1 - nTimeStart;
1555
- LogPrint (BCLog::BENCH, " - Sanity checks: %.2fms [%.2fs (%.2fms/blk)]\n " , 0.001 * (nTime1 - nTimeStart), nTimeCheck * 0.000001 , nTimeCheck * 0.001 / nBlocksTotal);
1558
+ LogPrint (BCLog::BENCH, " - Sanity checks: %.2fms [%.2fs (%.2fms/blk)]\n " , MILLI * (nTime1 - nTimeStart), nTimeCheck * MICRO , nTimeCheck * MILLI / nBlocksTotal);
1556
1559
1557
1560
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
1558
1561
// unless those are already completely spent.
@@ -1619,7 +1622,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1619
1622
}
1620
1623
1621
1624
int64_t nTime2 = GetTimeMicros (); nTimeForks += nTime2 - nTime1;
1622
- LogPrint (BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n " , 0.001 * (nTime2 - nTime1), nTimeForks * 0.000001 , nTimeForks * 0.001 / nBlocksTotal);
1625
+ LogPrint (BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n " , MILLI * (nTime2 - nTime1), nTimeForks * MICRO , nTimeForks * MILLI / nBlocksTotal);
1623
1626
1624
1627
CBlockUndo blockundo;
1625
1628
@@ -1693,7 +1696,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1693
1696
pos.nTxOffset += ::GetSerializeSize (tx, SER_DISK, CLIENT_VERSION);
1694
1697
}
1695
1698
int64_t nTime3 = GetTimeMicros (); nTimeConnect += nTime3 - nTime2;
1696
- LogPrint (BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs (%.2fms/blk)]\n " , (unsigned )block.vtx .size (), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx .size (), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1 ), nTimeConnect * 0.000001 , nTimeConnect * 0.001 / nBlocksTotal);
1699
+ LogPrint (BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs (%.2fms/blk)]\n " , (unsigned )block.vtx .size (), MILLI * (nTime3 - nTime2), MILLI * (nTime3 - nTime2) / block.vtx .size (), nInputs <= 1 ? 0 : MILLI * (nTime3 - nTime2) / (nInputs-1 ), nTimeConnect * MICRO , nTimeConnect * MILLI / nBlocksTotal);
1697
1700
1698
1701
CAmount blockReward = nFees + GetBlockSubsidy (pindex->nHeight , chainparams.GetConsensus ());
1699
1702
if (block.vtx [0 ]->GetValueOut () > blockReward)
@@ -1705,7 +1708,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1705
1708
if (!control.Wait ())
1706
1709
return state.DoS (100 , error (" %s: CheckQueue failed" , __func__), REJECT_INVALID, " block-validation-failed" );
1707
1710
int64_t nTime4 = GetTimeMicros (); nTimeVerify += nTime4 - nTime2;
1708
- LogPrint (BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs (%.2fms/blk)]\n " , nInputs - 1 , 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1 ), nTimeVerify * 0.000001 , nTimeVerify * 0.001 / nBlocksTotal);
1711
+ LogPrint (BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs (%.2fms/blk)]\n " , nInputs - 1 , MILLI * (nTime4 - nTime2), nInputs <= 1 ? 0 : MILLI * (nTime4 - nTime2) / (nInputs-1 ), nTimeVerify * MICRO , nTimeVerify * MILLI / nBlocksTotal);
1709
1712
1710
1713
if (fJustCheck )
1711
1714
return true ;
@@ -1737,10 +1740,10 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1737
1740
view.SetBestBlock (pindex->GetBlockHash ());
1738
1741
1739
1742
int64_t nTime5 = GetTimeMicros (); nTimeIndex += nTime5 - nTime4;
1740
- LogPrint (BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n " , 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001 , nTimeIndex * 0.001 / nBlocksTotal);
1743
+ LogPrint (BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n " , MILLI * (nTime5 - nTime4), nTimeIndex * MICRO , nTimeIndex * MILLI / nBlocksTotal);
1741
1744
1742
1745
int64_t nTime6 = GetTimeMicros (); nTimeCallbacks += nTime6 - nTime5;
1743
- LogPrint (BCLog::BENCH, " - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n " , 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001 , nTimeCallbacks * 0.001 / nBlocksTotal);
1746
+ LogPrint (BCLog::BENCH, " - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n " , MILLI * (nTime6 - nTime5), nTimeCallbacks * MICRO , nTimeCallbacks * MILLI / nBlocksTotal);
1744
1747
1745
1748
return true ;
1746
1749
}
@@ -1959,7 +1962,7 @@ bool static DisconnectTip(CValidationState& state, const CChainParams& chainpara
1959
1962
bool flushed = view.Flush ();
1960
1963
assert (flushed);
1961
1964
}
1962
- LogPrint (BCLog::BENCH, " - Disconnect block: %.2fms\n " , (GetTimeMicros () - nStart) * 0.001 );
1965
+ LogPrint (BCLog::BENCH, " - Disconnect block: %.2fms\n " , (GetTimeMicros () - nStart) * MILLI );
1963
1966
// Write the chain state to disk, if necessary.
1964
1967
if (!FlushStateToDisk (state, FLUSH_STATE_IF_NEEDED))
1965
1968
return false ;
@@ -2080,7 +2083,7 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
2080
2083
// Apply the block atomically to the chain state.
2081
2084
int64_t nTime2 = GetTimeMicros (); nTimeReadFromDisk += nTime2 - nTime1;
2082
2085
int64_t nTime3;
2083
- LogPrint (BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n " , (nTime2 - nTime1) * 0.001 , nTimeReadFromDisk * 0.000001 );
2086
+ LogPrint (BCLog::BENCH, " - Load block from disk: %.2fms [%.2fs]\n " , (nTime2 - nTime1) * MILLI , nTimeReadFromDisk * MICRO );
2084
2087
{
2085
2088
CCoinsViewCache view (pcoinsTip);
2086
2089
bool rv = ConnectBlock (blockConnecting, state, pindexNew, view, chainparams);
@@ -2091,26 +2094,26 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
2091
2094
return error (" ConnectTip(): ConnectBlock %s failed" , pindexNew->GetBlockHash ().ToString ());
2092
2095
}
2093
2096
nTime3 = GetTimeMicros (); nTimeConnectTotal += nTime3 - nTime2;
2094
- LogPrint (BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime3 - nTime2) * 0.001 , nTimeConnectTotal * 0.000001 , nTimeConnectTotal * 0.001 / nBlocksTotal);
2097
+ LogPrint (BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime3 - nTime2) * MILLI , nTimeConnectTotal * MICRO , nTimeConnectTotal * MILLI / nBlocksTotal);
2095
2098
bool flushed = view.Flush ();
2096
2099
assert (flushed);
2097
2100
}
2098
2101
int64_t nTime4 = GetTimeMicros (); nTimeFlush += nTime4 - nTime3;
2099
- LogPrint (BCLog::BENCH, " - Flush: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime4 - nTime3) * 0.001 , nTimeFlush * 0.000001 , nTimeFlush * 0.001 / nBlocksTotal);
2102
+ LogPrint (BCLog::BENCH, " - Flush: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime4 - nTime3) * MILLI , nTimeFlush * MICRO , nTimeFlush * MILLI / nBlocksTotal);
2100
2103
// Write the chain state to disk, if necessary.
2101
2104
if (!FlushStateToDisk (state, FLUSH_STATE_IF_NEEDED))
2102
2105
return false ;
2103
2106
int64_t nTime5 = GetTimeMicros (); nTimeChainState += nTime5 - nTime4;
2104
- LogPrint (BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime5 - nTime4) * 0.001 , nTimeChainState * 0.000001 , nTimeChainState * 0.001 / nBlocksTotal);
2107
+ LogPrint (BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime5 - nTime4) * MILLI , nTimeChainState * MICRO , nTimeChainState * MILLI / nBlocksTotal);
2105
2108
// Remove conflicting transactions from the mempool.;
2106
2109
mempool.removeForBlock (blockConnecting.vtx , pindexNew->nHeight );
2107
2110
disconnectpool.removeForBlock (blockConnecting.vtx );
2108
2111
// Update chainActive & related variables.
2109
2112
UpdateTip (pindexNew, chainparams);
2110
2113
2111
2114
int64_t nTime6 = GetTimeMicros (); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
2112
- LogPrint (BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime6 - nTime5) * 0.001 , nTimePostConnect * 0.000001 , nTimePostConnect * 0.001 / nBlocksTotal);
2113
- LogPrint (BCLog::BENCH, " - Connect block: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime6 - nTime1) * 0.001 , nTimeTotal * 0.000001 , nTimeTotal * 0.001 / nBlocksTotal);
2115
+ LogPrint (BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime6 - nTime5) * MILLI , nTimePostConnect * MICRO , nTimePostConnect * MILLI / nBlocksTotal);
2116
+ LogPrint (BCLog::BENCH, " - Connect block: %.2fms [%.2fs (%.2fms/blk)]\n " , (nTime6 - nTime1) * MILLI , nTimeTotal * MICRO , nTimeTotal * MILLI / nBlocksTotal);
2114
2117
2115
2118
connectTrace.BlockConnected (pindexNew, std::move (pthisBlock));
2116
2119
return true ;
@@ -4123,7 +4126,7 @@ void DumpMempool(void)
4123
4126
file.fclose ();
4124
4127
RenameOver (GetDataDir () / " mempool.dat.new" , GetDataDir () / " mempool.dat" );
4125
4128
int64_t last = GetTimeMicros ();
4126
- LogPrintf (" Dumped mempool: %gs to copy, %gs to dump\n " , (mid-start)*0.000001 , (last-mid)*0.000001 );
4129
+ LogPrintf (" Dumped mempool: %gs to copy, %gs to dump\n " , (mid-start)*MICRO , (last-mid)*MICRO );
4127
4130
} catch (const std::exception& e) {
4128
4131
LogPrintf (" Failed to dump mempool: %s. Continuing anyway.\n " , e.what ());
4129
4132
}
0 commit comments