Skip to content

Commit f93abe2

Browse files
authored
Merge pull request #1829 from KY-U/2026-05-fix-check-dead-code
fix(block::check) fix dead code on verification of empty block
2 parents 01cd140 + 49d7bdd commit f93abe2

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/chain/block.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,15 +876,15 @@ code block::identify(const context& ctx) const NOEXCEPT
876876
// Use of get_hash() in is_forward_reference makes this thread-unsafe.
877877
code block::check() const NOEXCEPT
878878
{
879-
// empty_block is subset of first_not_coinbase.
880879
// type64 malleated is a subset of first_not_coinbase.
881880
// type32 malleated is a subset of is_internal_double_spend.
882881
if (is_oversized())
883882
return error::block_size_limit;
883+
if (is_empty())
884+
return error::empty_block;
884885
if (is_first_non_coinbase())
885-
return (is_empty() ? error::empty_block :
886-
(is_malleated() ? error::invalid_transaction_commitment :
887-
error::first_not_coinbase));
886+
return (is_malleated() ? error::invalid_transaction_commitment :
887+
error::first_not_coinbase);
888888
if (is_extra_coinbases())
889889
return error::extra_coinbases;
890890
if (is_forward_reference())

test/chain/block.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ BOOST_AUTO_TEST_CASE(block__hash__default__matches_header_hash)
407407
// ----------------------------------------------------------------------------
408408

409409
// check
410+
BOOST_AUTO_TEST_CASE(block__check__empty__empty_block)
411+
{
412+
const block instance{};
413+
BOOST_REQUIRE_EQUAL(instance.check(), error::empty_block);
414+
}
410415
// accept
411416
// connect
412417

0 commit comments

Comments
 (0)