Skip to content

Commit

Permalink
broken math
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Dec 18, 2024
1 parent ea5180c commit 1471f36
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1930,13 +1930,15 @@ 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));
}
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);
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 1471f36

Please sign in to comment.