Skip to content

Commit

Permalink
Merge pull request #1394 from evoskuil/master
Browse files Browse the repository at this point in the history
Rename header.difficulty() to .proof(), rename max_stack_size.
  • Loading branch information
evoskuil authored Feb 13, 2024
2 parents f74548b + f714e01 commit 02d091d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/bitcoin/system/chain/enums/magic_numbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constexpr uint64_t sighash_null_value = max_uint64;
/// ---------------------------------------------------------------------------

constexpr size_t max_counted_ops = 201;
constexpr size_t max_stack_size = 1'000;
constexpr size_t max_unified_stack_size = 1'000;
constexpr size_t max_unified_script_size = 20'000;
constexpr size_t max_script_size = to_half(max_unified_script_size);
constexpr size_t max_push_data_size = 520;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/system/chain/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BC_API header

/// Computed properties.
hash_digest hash() const NOEXCEPT;
uint256_t difficulty() const NOEXCEPT;
uint256_t proof() const NOEXCEPT;

/// Cache (this overrides hash() computation).
void set_hash(hash_digest&& hash) const NOEXCEPT;
Expand Down Expand Up @@ -136,7 +136,7 @@ class BC_API header

private:
static header from_data(reader& source) NOEXCEPT;
static uint256_t difficulty(uint32_t bits) NOEXCEPT;
static uint256_t proof(uint32_t bits) NOEXCEPT;

// Header should be stored as shared (adds 16 bytes).
// copy: 4 * 32 + 2 * 256 + 1 = 81 bytes (vs. 16 when shared).
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/system/impl/machine/program.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ INLINE bool program<Stack>::
is_stack_overflow() const NOEXCEPT
{
// Addition is safe due to stack size constraint.
return (stack_size() + alternate_.size()) > max_stack_size;
return (stack_size() + alternate_.size()) > max_unified_stack_size;
}

// private
Expand Down
8 changes: 4 additions & 4 deletions src/chain/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ hash_digest header::hash() const NOEXCEPT
}

// static/private
uint256_t header::difficulty(uint32_t bits) NOEXCEPT
uint256_t header::proof(uint32_t bits) NOEXCEPT
{
auto target = compact::expand(bits);

Expand All @@ -276,10 +276,10 @@ uint256_t header::difficulty(uint32_t bits) NOEXCEPT
}

// computed
uint256_t header::difficulty() const NOEXCEPT
uint256_t header::proof() const NOEXCEPT
{
// Returns zero if bits_ mantissa is less than one or bits_ is overflowed.
return difficulty(bits_);
return proof(bits_);
}

// Check.
Expand Down Expand Up @@ -307,7 +307,7 @@ bool header::is_invalid_proof_of_work(uint32_t proof_of_work_limit,
}

// ****************************************************************************
/// CONSENSUS: bitcoin 32bit unix time: en.wikipedia.org/wiki/Year_2038_problem
// CONSENSUS: bitcoin 32bit unix time: en.wikipedia.org/wiki/Year_2038_problem
// ****************************************************************************
bool header::is_invalid_timestamp(
uint32_t timestamp_limit_seconds) const NOEXCEPT
Expand Down
4 changes: 2 additions & 2 deletions test/chain/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ BOOST_AUTO_TEST_CASE(header__to_data__writer__expected)

// hash

BOOST_AUTO_TEST_CASE(header__difficulty__genesis_block__expected)
BOOST_AUTO_TEST_CASE(header__proof__genesis_block__expected)
{
const chain::block block{ settings(selection::mainnet).genesis_block };
BOOST_REQUIRE_EQUAL(block.header().difficulty(), 0x0000000100010001);
BOOST_REQUIRE_EQUAL(block.header().proof(), 0x0000000100010001);
}

// validation (public)
Expand Down

0 comments on commit 02d091d

Please sign in to comment.