diff --git a/src/impl/dgb/share_tracker.hpp b/src/impl/dgb/share_tracker.hpp index dc1a5a17f..f404945ef 100644 --- a/src/impl/dgb/share_tracker.hpp +++ b/src/impl/dgb/share_tracker.hpp @@ -29,6 +29,7 @@ inline uint64_t mul128_shift(uint64_t a, uint64_t b, unsigned shift) { #include // SSOT: accumulate_version_weights / accumulate_version_counts (#429 follow-on) #include "coin/pool_attempts_per_second.hpp" // SSOT: compute_pool_attempts_per_second (#407 follow-on) #include "coin/tail_score_endpoints.hpp" // SSOT: score_* endpoint arithmetic (ShareTracker::score chain-walk, #411 follow-on) +#include "coin/chain_walk_window.hpp" // SSOT: lookbehind clamp (#423 diag follow-on); consensus get_desired_version_weights stays inline #include "config_pool.hpp" #include @@ -2059,8 +2060,8 @@ class ShareTracker float get_average_stale_prop(const uint256& share_hash, uint64_t lookbehind) { auto height = chain.get_height(share_hash); - auto actual_lookbehind = std::min(static_cast(lookbehind), height); - if (actual_lookbehind <= 0) + auto actual_lookbehind = dgb::chain_walk_window_count(height, static_cast(lookbehind)); + if (!dgb::chain_walk_window_active(actual_lookbehind)) return 0.0f; float stale_count = 0; @@ -2081,8 +2082,8 @@ class ShareTracker { StaleCounts counts; auto height = chain.get_height(share_hash); - auto actual_lookbehind = std::min(static_cast(lookbehind), height); - if (actual_lookbehind <= 0) + auto actual_lookbehind = dgb::chain_walk_window_count(height, static_cast(lookbehind)); + if (!dgb::chain_walk_window_active(actual_lookbehind)) return counts; auto view = chain.get_chain(share_hash, actual_lookbehind); @@ -2127,8 +2128,8 @@ class ShareTracker if (!chain.contains(share_hash)) return {}; auto height = chain.get_height(share_hash); - auto actual = std::min(lookbehind, height); - if (actual <= 0) + auto actual = dgb::chain_walk_window_count(height, lookbehind); + if (!dgb::chain_walk_window_active(actual)) return {}; std::vector window;