@@ -539,30 +539,29 @@ impl HistoricalMinMaxBuckets<'_> {
539
539
#[ inline]
540
540
fn calculate_success_probability_times_billion ( & self , required_decays : u32 , payment_amt_64th_bucket : u8 ) -> Option < u64 > {
541
541
// If historical penalties are enabled, calculate the penalty by walking the set of
542
- // historical liquidity bucket (min, max) combinations (where min_idx < max_idx)
543
- // and, for each, calculate the probability of success given our payment amount, then
544
- // total the weighted average probability of success.
542
+ // historical liquidity bucket (min, max) combinations (where min_idx < max_idx) and, for
543
+ // each, calculate the probability of success given our payment amount, then total the
544
+ // weighted average probability of success.
545
545
//
546
- // We use a sliding scale to decide which point within a given bucket will be compared
547
- // to the amount being sent - for lower-bounds, the amount being sent is compared to
548
- // the lower edge of the first bucket (i.e. zero), but compared to the upper 7/8ths of
549
- // the last bucket (i.e. 9 times the index, or 63), with each bucket in between
550
- // increasing the comparison point by 1/64th. For upper-bounds, the same applies,
551
- // however with an offset of 1/64th (i.e. starting at one and ending at 64). This
552
- // avoids failing to assign penalties to channels at the edges.
546
+ // We use a sliding scale to decide which point within a given bucket will be compared to
547
+ // the amount being sent - for lower-bounds, the amount being sent is compared to the lower
548
+ // edge of the first bucket (i.e. zero), but compared to the upper 7/8ths of the last
549
+ // bucket (i.e. 9 times the index, or 63), with each bucket in between increasing the
550
+ // comparison point by 1/64th. For upper-bounds, the same applies, however with an offset
551
+ // of 1/64th (i.e. starting at one and ending at 64). This avoids failing to assign
552
+ // penalties to channels at the edges.
553
553
//
554
- // If we used the bottom edge of buckets, we'd end up never assigning any penalty at
555
- // all to such a channel when sending less than ~0.19% of the channel's capacity (e.g.
556
- // ~200k sats for a 1 BTC channel!).
554
+ // If we used the bottom edge of buckets, we'd end up never assigning any penalty at all to
555
+ // such a channel when sending less than ~0.19% of the channel's capacity (e.g. ~200k sats
556
+ // for a 1 BTC channel!).
557
557
//
558
- // If we used the middle of each bucket we'd never assign any penalty at all when
559
- // sending less than 1/16th of a channel's capacity, or 1/8th if we used the top of the
560
- // bucket.
558
+ // If we used the middle of each bucket we'd never assign any penalty at all when sending
559
+ // less than 1/16th of a channel's capacity, or 1/8th if we used the top of the bucket.
561
560
let mut total_valid_points_tracked = 0 ;
562
561
563
562
// Rather than actually decaying the individual buckets, which would lose precision, we
564
- // simply track whether all buckets would be decayed to zero, in which case we treat it
565
- // as if we had no data.
563
+ // simply track whether all buckets would be decayed to zero, in which case we treat it as
564
+ // if we had no data.
566
565
let mut is_fully_decayed = true ;
567
566
let mut check_track_bucket_contains_undecayed_points =
568
567
|bucket_val : u16 | if bucket_val. checked_shr ( required_decays) . unwrap_or ( 0 ) > 0 { is_fully_decayed = false ; } ;
@@ -574,8 +573,8 @@ impl HistoricalMinMaxBuckets<'_> {
574
573
check_track_bucket_contains_undecayed_points ( * max_bucket) ;
575
574
}
576
575
}
577
- // If the total valid points is smaller than 1.0 (i.e. 32 in our fixed-point scheme),
578
- // treat it as if we were fully decayed.
576
+ // If the total valid points is smaller than 1.0 (i.e. 32 in our fixed-point scheme), treat
577
+ // it as if we were fully decayed.
579
578
if total_valid_points_tracked. checked_shr ( required_decays) . unwrap_or ( 0 ) < 32 * 32 || is_fully_decayed {
580
579
return None ;
581
580
}
0 commit comments