Skip to content

Commit 89d8c45

Browse files
UdjinM6claude
andcommitted
assert: use ASSERT_IF_DEBUG for known_hash invariants
Switch the known_hash debug invariants from assert() to ASSERT_IF_DEBUG() so the extra X11 hashing only occurs in debug builds. Dash always compiles with assertions enabled, so plain assert() would add unnecessary overhead in release builds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01e72cb commit 89d8c45

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3977,7 +3977,7 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
39773977

39783978
auto start = Now<SteadyMicroseconds>();
39793979

3980-
assert(!known_hash || *known_hash == block.GetHash());
3980+
ASSERT_IF_DEBUG(!known_hash || *known_hash == block.GetHash());
39813981

39823982
if (block.fChecked)
39833983
return true;
@@ -4189,7 +4189,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
41894189
{
41904190
AssertLockHeld(cs_main);
41914191

4192-
assert(hash == block.GetHash());
4192+
ASSERT_IF_DEBUG(hash == block.GetHash());
41934193

41944194
// TODO : ENABLE BLOCK CACHE IN SPECIFIC CASES
41954195
BlockMap::iterator miSelf{m_blockman.m_block_index.find(hash)};
@@ -4358,7 +4358,7 @@ bool CChainState::AcceptBlock(const std::shared_ptr<const CBlock>& pblock, Block
43584358
CBlockIndex *pindexDummy = nullptr;
43594359
CBlockIndex *&pindex = ppindex ? *ppindex : pindexDummy;
43604360

4361-
assert(!known_hash || *known_hash == block.GetHash());
4361+
ASSERT_IF_DEBUG(!known_hash || *known_hash == block.GetHash());
43624362

43634363
const uint256 hash{known_hash ? *known_hash : block.GetHash()};
43644364
bool accepted_header{m_chainman.AcceptBlockHeader(block, state, &pindex, hash)};

0 commit comments

Comments
 (0)