Skip to content

Commit

Permalink
Style.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 4, 2024
1 parent 16c1422 commit af02dae
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions src/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,21 +727,16 @@ code block::confirm_transactions(const context& ctx) const NOEXCEPT
// TODO: use of get_hash() in is_forward_reference makes this thread unsafe.
code block::check(bool bypass) const NOEXCEPT
{
if (bypass)
{
// Transaction commitment is required under checkpoint.
if (is_invalid_merkle_root())
return error::invalid_transaction_commitment;

// type32_malleated is subset of is_internal_double_spend, assuming
// otherwise valid txs, as that will catch any duplicated transaction.
if (is_malleated32())
return error::type32_malleated;
if (is_invalid_merkle_root())
return error::invalid_transaction_commitment;

// type32_malleated is subset of is_internal_double_spend
if (bypass && is_malleated32())
return error::type32_malleated;
if (bypass)
return error::block_success;
}

// empty_block is redundant with first_not_coinbase.
// empty_block is subset of first_not_coinbase.
//if (is_empty())
// return error::empty_block;
if (is_oversized())
Expand All @@ -754,8 +749,6 @@ code block::check(bool bypass) const NOEXCEPT
return error::forward_reference;
if (is_internal_double_spend())
return error::block_internal_double_spend;
if (is_invalid_merkle_root())
return error::invalid_transaction_commitment;

return check_transactions();
}
Expand All @@ -769,29 +762,23 @@ code block::check(bool bypass) const NOEXCEPT
// TODO: use of get_hash() in is_hash_limit_exceeded makes this thread unsafe.
code block::check(const context& ctx, bool bypass) const NOEXCEPT
{
if (bypass)
{
const auto bip141 = ctx.is_enabled(bip141_rule);
const auto bip141 = ctx.is_enabled(bip141_rule);

if (bip141 && is_invalid_witness_commitment())
return error::invalid_witness_commitment;

// Wintness commitment is required under checkpoint.
if (bip141 && is_invalid_witness_commitment())
return error::invalid_witness_commitment;

if (bypass)
return error::block_success;
}

const auto bip34 = ctx.is_enabled(bip34_rule);
const auto bip50 = ctx.is_enabled(bip50_rule);
const auto bip141 = ctx.is_enabled(bip141_rule);

if (bip141 && is_overweight())
return error::block_weight_limit;
if (bip34 && is_invalid_coinbase_script(ctx.height))
return error::coinbase_height_mismatch;
if (bip50 && is_hash_limit_exceeded())
return error::temporary_hash_limit;
if (bip141 && is_invalid_witness_commitment())
return error::invalid_witness_commitment;

return check_transactions(ctx);
}
Expand Down

0 comments on commit af02dae

Please sign in to comment.