Skip to content

Commit 8fbbe8f

Browse files
committed
f add comments
1 parent 9fb4ef5 commit 8fbbe8f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lightning/src/routing/scoring.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,9 @@ mod bucketed_history {
18641864
let mut total_valid_points_tracked = 0;
18651865
for (min_idx, min_bucket) in self.min_liquidity_offset_history.buckets.iter().enumerate() {
18661866
for max_bucket in self.max_liquidity_offset_history.buckets.iter().take(32 - min_idx) {
1867+
// In testing, raising the weights of buckets to a high power led to better
1868+
// scoring results. Thus, we raise the bucket weights to the 4th power here (by
1869+
// squaring the result of multiplying the weights).
18671870
let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64);
18681871
bucket_weight *= bucket_weight;
18691872
total_valid_points_tracked += bucket_weight;
@@ -1992,6 +1995,10 @@ mod bucketed_history {
19921995
if *max_bucket != 0 {
19931996
highest_max_bucket_with_points = cmp::max(highest_max_bucket_with_points, max_idx);
19941997
}
1998+
// In testing, raising the weights of buckets to a high power led to better
1999+
// scoring results. Thus, we raise the bucket weights to the 4th power here (by
2000+
// squaring the result of multiplying the weights), matching the logic in
2001+
// `recalculate_valid_point_count`.
19952002
total_weight += (*max_bucket as u64) * (*max_bucket as u64)
19962003
* (min_liquidity_offset_history_buckets[0] as u64) * (min_liquidity_offset_history_buckets[0] as u64);
19972004
}
@@ -2015,16 +2022,20 @@ mod bucketed_history {
20152022
let min_bucket_start_pos = BUCKET_START_POS[min_idx];
20162023
for (max_idx, max_bucket) in max_liquidity_offset_history_buckets.iter().enumerate().take(32 - min_idx) {
20172024
let max_bucket_end_pos = BUCKET_START_POS[32 - max_idx] - 1;
2018-
let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64);
2019-
bucket_weight *= bucket_weight;
2020-
debug_assert!(bucket_weight as f64 <= total_valid_points_tracked);
2021-
20222025
if payment_pos >= max_bucket_end_pos {
20232026
// Success probability 0, the payment amount may be above the max liquidity
20242027
break;
20252028
}
20262029

2030+
// In testing, raising the weights of buckets to a high power led to better
2031+
// scoring results. Thus, we raise the bucket weights to the 4th power here (by
2032+
// squaring the result of multiplying the weights), matching the logic in
2033+
// `recalculate_valid_point_count`.
2034+
let mut bucket_weight = (*min_bucket as u64) * (*max_bucket as u64);
2035+
bucket_weight *= bucket_weight;
2036+
debug_assert!(bucket_weight as f64 <= total_valid_points_tracked);
20272037
let bucket_prob = bucket_weight as f64 / total_valid_points_tracked;
2038+
20282039
if payment_pos < min_bucket_start_pos {
20292040
cumulative_success_prob += bucket_prob;
20302041
} else {

0 commit comments

Comments
 (0)