Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkpointed bypass parameter in block.check. #1472

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading