@@ -1074,26 +1074,30 @@ fn three_f64_pow_3(a: f64, b: f64, c: f64) -> (f64, f64, f64) {
1074
1074
///
1075
1075
/// Must not return a numerator or denominator greater than 2^31 for arguments less than 2^31.
1076
1076
///
1077
+ /// `total_inflight_amount_msat` includes the amount of the HTLC and any HTLCs in flight over the
1078
+ /// channel.
1079
+ ///
1077
1080
/// min_zero_implies_no_successes signals that a `min_liquidity_msat` of 0 means we've not
1078
1081
/// (recently) seen an HTLC successfully complete over this channel.
1079
1082
#[ inline( always) ]
1080
1083
fn success_probability (
1081
- amount_msat : u64 , min_liquidity_msat : u64 , max_liquidity_msat : u64 , capacity_msat : u64 ,
1082
- params : & ProbabilisticScoringFeeParameters , min_zero_implies_no_successes : bool ,
1084
+ total_inflight_amount_msat : u64 , min_liquidity_msat : u64 , max_liquidity_msat : u64 ,
1085
+ capacity_msat : u64 , params : & ProbabilisticScoringFeeParameters ,
1086
+ min_zero_implies_no_successes : bool ,
1083
1087
) -> ( u64 , u64 ) {
1084
- debug_assert ! ( min_liquidity_msat <= amount_msat ) ;
1085
- debug_assert ! ( amount_msat < max_liquidity_msat) ;
1088
+ debug_assert ! ( min_liquidity_msat <= total_inflight_amount_msat ) ;
1089
+ debug_assert ! ( total_inflight_amount_msat < max_liquidity_msat) ;
1086
1090
debug_assert ! ( max_liquidity_msat <= capacity_msat) ;
1087
1091
1088
1092
let ( numerator, mut denominator) =
1089
1093
if params. linear_success_probability {
1090
- ( max_liquidity_msat - amount_msat ,
1094
+ ( max_liquidity_msat - total_inflight_amount_msat ,
1091
1095
( max_liquidity_msat - min_liquidity_msat) . saturating_add ( 1 ) )
1092
1096
} else {
1093
1097
let capacity = capacity_msat as f64 ;
1094
1098
let min = ( min_liquidity_msat as f64 ) / capacity;
1095
1099
let max = ( max_liquidity_msat as f64 ) / capacity;
1096
- let amount = ( amount_msat as f64 ) / capacity;
1100
+ let amount = ( total_inflight_amount_msat as f64 ) / capacity;
1097
1101
1098
1102
// Assume the channel has a probability density function of (x - 0.5)^2 for values from
1099
1103
// 0 to 1 (where 1 is the channel's full capacity). The success probability given some
@@ -1779,7 +1783,7 @@ mod bucketed_history {
1779
1783
1780
1784
#[ inline]
1781
1785
pub ( super ) fn calculate_success_probability_times_billion (
1782
- & self , params : & ProbabilisticScoringFeeParameters , amount_msat : u64 ,
1786
+ & self , params : & ProbabilisticScoringFeeParameters , total_inflight_amount_msat : u64 ,
1783
1787
capacity_msat : u64
1784
1788
) -> Option < u64 > {
1785
1789
// If historical penalties are enabled, we try to calculate a probability of success
@@ -1789,7 +1793,7 @@ mod bucketed_history {
1789
1793
// state). For each pair, we calculate the probability as if the bucket's corresponding
1790
1794
// min- and max- liquidity bounds were our current liquidity bounds and then multiply
1791
1795
// that probability by the weight of the selected buckets.
1792
- let payment_pos = amount_to_pos ( amount_msat , capacity_msat) ;
1796
+ let payment_pos = amount_to_pos ( total_inflight_amount_msat , capacity_msat) ;
1793
1797
if payment_pos >= POSITION_TICKS { return None ; }
1794
1798
1795
1799
let min_liquidity_offset_history_buckets =
0 commit comments