Skip to content

Commit

Permalink
fuck
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Dec 18, 2024
1 parent 1f3e604 commit 1666347
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lightning/src/routing/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ mod bucketed_history {
let mut highest_max_bucket_with_points = 0;
let mut highest_max_bucket_with_full_points = None;
let mut total_max_points = 0; // Total points in max-buckets to consider
let mut total_weight = 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));
Expand All @@ -1923,6 +1924,7 @@ mod bucketed_history {
highest_max_bucket_with_points = cmp::max(highest_max_bucket_with_points, max_idx);
}
total_max_points += *max_bucket as u64;
total_weight += (min_liquidity_offset_history_buckets[0] as u128) * (*max_bucket as u128) * (min_liquidity_offset_history_buckets[0] as u128) * (*max_bucket as u128);
}
// Use the highest max-bucket with at least BUCKET_FIXED_POINT_ONE, but if none is
// available use the highest max-bucket with any non-zero value. This ensures that
Expand All @@ -1934,9 +1936,11 @@ mod bucketed_history {
if payment_pos < max_bucket_end_pos {
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 =
/*let mut bucket_weight =
(min_liquidity_offset_history_buckets[0] as u128) * (total_max_points as u128);
bucket_weight *= bucket_weight;
bucket_weight *= bucket_weight;*/
let bucket_weight = total_weight;
debug_assert!(bucket_weight <= total_valid_points_tracked);
let bucket_prob_times_billion =
bucket_weight * 1024 * 1024 * 1024 / total_valid_points_tracked;
debug_assert!(bucket_prob_times_billion <= 1 << 30);
Expand All @@ -1951,6 +1955,7 @@ mod bucketed_history {
let max_bucket_end_pos = BUCKET_START_POS[32 - max_idx] - 1;
let mut bucket_weight = (*min_bucket as u128) * (*max_bucket as u128);
bucket_weight *= bucket_weight;
debug_assert!(bucket_weight <= total_valid_points_tracked);
let bucket_prob_times_billion =
bucket_weight * 1024 * 1024 * 1024 / total_valid_points_tracked;
debug_assert!(bucket_prob_times_billion <= 1 << 30);
Expand Down

0 comments on commit 1666347

Please sign in to comment.