Skip to content

Commit a3599bb

Browse files
authored
Merge pull request #504 from frstrtr/dgb/tail-score-prod-rewire-411
dgb: rewire ShareTracker::score onto coin/ tail_score SSOT (#411 follow-on)
2 parents e7bf7d1 + ec12d70 commit a3599bb

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/impl/dgb/share_tracker.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ inline uint64_t mul128_shift(uint64_t a, uint64_t b, unsigned shift) {
2828
#include "coin/naughty_propagation.hpp" // SSOT: propagate_naughty_from_parent (data.py:543-549)
2929
#include <impl/dgb/coin/desired_version_tally.hpp> // SSOT: accumulate_version_weights / accumulate_version_counts (#429 follow-on)
3030
#include "coin/pool_attempts_per_second.hpp" // SSOT: compute_pool_attempts_per_second (#407 follow-on)
31+
#include "coin/tail_score_endpoints.hpp" // SSOT: score_* endpoint arithmetic (ShareTracker::score chain-walk, #411 follow-on)
3132
#include "config_pool.hpp"
3233

3334
#include <core/target_utils.hpp>
@@ -605,19 +606,19 @@ class ShareTracker
605606
// unverified shares, causing short verified chains to tie on
606607
// chain_len with long chains and win on hashrate tiebreak.
607608
auto head_height = verified.get_acc_height(share_hash);
608-
if (head_height < static_cast<int32_t>(PoolConfig::chain_length()))
609+
if (score_head_too_short(head_height, static_cast<int32_t>(PoolConfig::chain_length())))
609610
return {head_height, score_res};
610611

611612
// p2pool: end_point = self.verified.get_nth_parent_hash(
612613
// share_hash, self.net.CHAIN_LENGTH*15//16)
613614
// SubsetTracker delegates to parent's skip list (shared navigation).
614615
auto end_point = verified.get_nth_parent_via_skip(share_hash,
615-
(PoolConfig::chain_length() * 15) / 16);
616+
score_endpoint_offset(static_cast<int32_t>(PoolConfig::chain_length())));
616617

617618
// p2pool: self.verified.get_chain(end_point, self.net.CHAIN_LENGTH//16)
618619
std::optional<int32_t> block_height;
619-
auto tail_count = std::min(
620-
static_cast<int32_t>(PoolConfig::chain_length() / 16),
620+
auto tail_count = score_tail_walk_count(
621+
static_cast<int32_t>(PoolConfig::chain_length()),
621622
verified.get_acc_height(end_point));
622623
if (tail_count <= 0)
623624
return {static_cast<int32_t>(PoolConfig::chain_length()), score_res};
@@ -643,8 +644,8 @@ class ShareTracker
643644
// confirmation count so the score is tiny but non-zero, preventing
644645
// oscillation where short chains beat long chains simply because the
645646
// long chain's old blocks are unresolvable.
646-
if (!block_height.has_value() || block_height.value() <= 0)
647-
block_height = 1000000; // ~1M confirmations → time_span ≈ 75M seconds
647+
block_height = score_resolved_block_span(
648+
block_height.has_value(), block_height.value_or(0)); // ~1M conf when unresolved → time_span ≈ 75M seconds
648649

649650
// p2pool: self.verified.get_delta(share_hash, end_point).work
650651
auto total_work = verified.get_delta_work(share_hash, end_point);
@@ -653,11 +654,10 @@ class ShareTracker
653654
// c2pool confirmations: 1=tip → 75s, 4 → 300s (matches p2pool).
654655
// BLOCK_PERIOD sourced from the make_coin_params-populated CoinParams
655656
// (oracle PARENT.BLOCK_PERIOD, config_coin.hpp = 75s) — no hardcoded holdover.
656-
auto time_span = block_height.value() * static_cast<int32_t>(m_params->block_period);
657-
if (time_span <= 0)
658-
time_span = 1;
657+
auto time_span = score_time_span(
658+
block_height.value(), static_cast<int32_t>(m_params->block_period));
659659

660-
score_res = total_work / static_cast<uint32_t>(time_span);
660+
score_res = score_value(total_work, time_span);
661661
return {static_cast<int32_t>(PoolConfig::chain_length()), score_res};
662662
}
663663

0 commit comments

Comments
 (0)