Skip to content
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
10 changes: 4 additions & 6 deletions include/bitcoin/database/impl/query/consensus/consensus_work.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool CLASS::get_branch(header_states& branch,

TEMPLATE
bool CLASS::get_strong_branch(bool& strong, const uint256_t& branch_work,
size_t branch_point) const NOEXCEPT
size_t branch_point, bool tie) const NOEXCEPT
{
uint256_t work{};
for (auto height = get_top_candidate(); height > branch_point; --height)
Expand All @@ -71,9 +71,8 @@ bool CLASS::get_strong_branch(bool& strong, const uint256_t& branch_work,
if (!get_bits(bits, to_candidate(height)))
return false;

// Not strong when candidate_work equals or exceeds branch_work.
work += system::chain::header::proof(bits);
if (work >= branch_work)
if (tie ? (work > branch_work) : (work >= branch_work))
{
strong = false;
return true;
Expand All @@ -86,7 +85,7 @@ bool CLASS::get_strong_branch(bool& strong, const uint256_t& branch_work,

TEMPLATE
bool CLASS::get_strong_fork(bool& strong, const uint256_t& fork_work,
size_t fork_point) const NOEXCEPT
size_t fork_point, bool tie) const NOEXCEPT
{
uint256_t work{};
for (auto height = get_top_confirmed(); height > fork_point; --height)
Expand All @@ -95,9 +94,8 @@ bool CLASS::get_strong_fork(bool& strong, const uint256_t& fork_work,
if (!get_bits(bits, to_confirmed(height)))
return false;

// Not strong is confirmed work ever equals or exceeds fork_work.
work += system::chain::header::proof(bits);
if (work >= fork_work)
if (tie ? (work > fork_work) : (work >= fork_work))
{
strong = false;
return true;
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,9 @@ class query
bool get_branch(header_states& branch, const hash_digest& hash) const NOEXCEPT;
bool get_work(uint256_t& work, const header_states& states) const NOEXCEPT;
bool get_strong_branch(bool& strong, const uint256_t& branch_work,
size_t branch_point) const NOEXCEPT;
size_t branch_point, bool tie=false) const NOEXCEPT;
bool get_strong_fork(bool& strong, const uint256_t& fork_work,
size_t fork_point) const NOEXCEPT;
size_t fork_point, bool tie=false) const NOEXCEPT;

/// Height indexation.
/// -----------------------------------------------------------------------
Expand Down
Loading