diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index ad58da1f5f6..ead7d4ffada 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -1748,7 +1748,7 @@ mod bucketed_history { // Because the first thing we do is check if `total_valid_points` is sufficient to consider // the data here at all, and can return early if it is not, we want this to go first to // avoid hitting a second cache line load entirely in that case. - total_valid_points_tracked: u64, + total_valid_points_tracked: u128, min_liquidity_offset_history: HistoricalBucketRangeTracker, max_liquidity_offset_history: HistoricalBucketRangeTracker, } @@ -1795,9 +1795,8 @@ mod bucketed_history { self.total_valid_points_tracked = 0; for (min_idx, min_bucket) in self.min_liquidity_offset_history.buckets.iter().enumerate() { for max_bucket in self.max_liquidity_offset_history.buckets.iter().take(32 - min_idx) { - let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64); + let mut bucket_weight = (*min_bucket as u128) * (*max_bucket as u128); bucket_weight *= bucket_weight; - debug_assert!(bucket_weight < (1 << 54)); self.total_valid_points_tracked += bucket_weight; } } @@ -1886,7 +1885,7 @@ mod bucketed_history { let mut actual_valid_points_tracked = 0; for (min_idx, min_bucket) in min_liquidity_offset_history_buckets.iter().enumerate() { for max_bucket in max_liquidity_offset_history_buckets.iter().take(32 - min_idx) { - let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64); + let mut bucket_weight = (*min_bucket as u128) * (*max_bucket as u128); bucket_weight *= bucket_weight; actual_valid_points_tracked += bucket_weight; } @@ -1936,7 +1935,7 @@ mod bucketed_history { let (numerator, denominator) = success_probability(payment_pos as u64, 0, max_bucket_end_pos as u64, POSITION_TICKS as u64 - 1, params, true); let mut bucket_weight = - (min_liquidity_offset_history_buckets[0] as u64) * total_max_points; + (min_liquidity_offset_history_buckets[0] as u128) * (total_max_points as u128); bucket_weight *= bucket_weight; let bucket_prob_times_billion = bucket_weight * 1024 * 1024 * 1024 / total_valid_points_tracked; @@ -1950,7 +1949,7 @@ mod bucketed_history { let min_bucket_start_pos = BUCKET_START_POS[min_idx]; for (max_idx, max_bucket) in max_liquidity_offset_history_buckets.iter().enumerate().take(32 - min_idx) { let max_bucket_end_pos = BUCKET_START_POS[32 - max_idx] - 1; - let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64); + let mut bucket_weight = (*min_bucket as u128) * (*max_bucket as u128); bucket_weight *= bucket_weight; let bucket_prob_times_billion = bucket_weight * 1024 * 1024 * 1024 / total_valid_points_tracked;