Skip to content

Commit

Permalink
Merge pull request #1472 from evoskuil/master
Browse files Browse the repository at this point in the history
Add checkpointed bypass parameter in block.check.
  • Loading branch information
evoskuil authored Jun 1, 2024
2 parents 170b19d + dfe233c commit e47b9bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class BC_API block
/// -----------------------------------------------------------------------

/// Consensus checks (no DoS guards for block sync without headers first).
code check() const NOEXCEPT;
code check(const context& ctx) const NOEXCEPT;
code check(bool bypass=false) const NOEXCEPT;
code check(const context& ctx, bool bypass=false) const NOEXCEPT;
code accept(const context& ctx, size_t subsidy_interval,
uint64_t initial_subsidy) const NOEXCEPT;
code connect(const context& ctx) const NOEXCEPT;
Expand Down
17 changes: 15 additions & 2 deletions src/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,14 @@ code block::confirm_transactions(const context& ctx) const NOEXCEPT
// ----------------------------------------------------------------------------
// The block header is checked/accepted independently.

code block::check() const NOEXCEPT
code block::check(bool bypass) const NOEXCEPT
{
if (bypass)
{
return is_invalid_merkle_root() ? error::merkle_mismatch :
error::block_success;
}

// context free.
// empty_block is redundant with first_not_coinbase.
//if (is_empty())
Expand All @@ -750,8 +756,15 @@ code block::check() const NOEXCEPT
// timestamp
// median_time_past

code block::check(const context& ctx) const NOEXCEPT
code block::check(const context& ctx, bool bypass) const NOEXCEPT
{
if (bypass)
{
const auto bip141 = ctx.is_enabled(bip141_rule);
return bip141 && is_invalid_witness_commitment() ?
error::invalid_witness_commitment : 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);
Expand Down

0 comments on commit e47b9bf

Please sign in to comment.