From 1471f367877e0083724d8ba2027397bd72ed9ef5 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 18 Dec 2024 22:10:45 +0000 Subject: [PATCH] broken math --- lightning/src/routing/scoring.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 1cc8f363058..9eb62d350e9 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -1930,6 +1930,7 @@ mod bucketed_history { let mut highest_max_bucket_with_points = 0; let mut highest_max_bucket_with_full_points = None; let mut total_weight = 0; + let mut count = 0; for (max_idx, max_bucket) in max_liquidity_offset_history_buckets.iter().enumerate() { if *max_bucket >= BUCKET_FIXED_POINT_ONE { highest_max_bucket_with_full_points = Some(cmp::max(highest_max_bucket_with_full_points.unwrap_or(0), max_idx)); @@ -1937,6 +1938,7 @@ mod bucketed_history { if *max_bucket != 0 { highest_max_bucket_with_points = cmp::max(highest_max_bucket_with_points, max_idx); } + count += *max_bucket as u64; total_weight += (*max_bucket as u64) * (*max_bucket as u64) * (min_liquidity_offset_history_buckets[0] as u64) * (min_liquidity_offset_history_buckets[0] as u64); } @@ -1951,6 +1953,8 @@ mod bucketed_history { if payment_pos < max_bucket_end_pos { let (numerator, denominator) = success_probability_float(payment_pos as u64, 0, max_bucket_end_pos as u64, POSITION_TICKS as u64 - 1, params, true); + let alt_weight = count * (min_liquidity_offset_history_buckets[0] as u64); + let total_weight = alt_weight * alt_weight; let bucket_prob = total_weight as f64 / total_valid_points_tracked; cumulative_success_prob += bucket_prob * numerator / denominator; }