mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
block_connected: don't serialize block hash twice
In the validation:block_connected tracepoint, we call block->GetHash(), which ends up calling CBlockHeader::GetHash(), executing around 8000 serialization instructions. We don't need to do this extra work, because block->GetHash() is already called further up in the function. Let's save that value as a local variable and re-use it in our tracepoint so there is no unnecessary tracepoint overhead. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
95194d28e9
commit
7f2c84b7be
@ -1978,7 +1978,10 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||
|
||||
AssertLockHeld(cs_main);
|
||||
assert(pindex);
|
||||
assert(*pindex->phashBlock == block.GetHash());
|
||||
|
||||
uint256 block_hash{block.GetHash()};
|
||||
assert(*pindex->phashBlock == block_hash);
|
||||
|
||||
assert(m_clhandler);
|
||||
assert(m_isman);
|
||||
assert(m_quorum_block_processor);
|
||||
@ -2026,7 +2029,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||
|
||||
// Special case for the genesis block, skipping connection of its transactions
|
||||
// (its coinbase is unspendable)
|
||||
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
|
||||
if (block_hash == chainparams.GetConsensus().hashGenesisBlock) {
|
||||
if (!fJustCheck)
|
||||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user