@@ -118,7 +118,8 @@ pub trait ScoreLookUp {
118
118
/// This is useful to determine whether a channel should be included in a blinded path and the
119
119
/// preferred ordering of blinded paths.
120
120
fn channel_success_probability(
121
- & self , _short_channel_id: u64 , _info: & DirectedChannelInfo , _usage: ChannelUsage
121
+ & self , _short_channel_id: u64 , _info: & DirectedChannelInfo , _usage: ChannelUsage ,
122
+ _score_params: & Self :: ScoreParams
122
123
) -> f64 { 0.5 }
123
124
124
125
/// Returns how certain any knowledge gained about the channel's liquidity balance is.
@@ -1251,6 +1252,27 @@ DirectedChannelLiquidity< L, BRT, T> {
1251
1252
liquidity_penalty_msat. saturating_add ( amount_penalty_msat)
1252
1253
}
1253
1254
1255
+ fn success_probability (
1256
+ & self , usage : ChannelUsage , score_params : & ProbabilisticScoringFeeParameters
1257
+ ) -> f64 {
1258
+ let amount_msat = usage. amount_msat ;
1259
+ let available_capacity = self . capacity_msat ;
1260
+ let max_liquidity_msat = self . max_liquidity_msat ( ) ;
1261
+ let min_liquidity_msat = core:: cmp:: min ( self . min_liquidity_msat ( ) , max_liquidity_msat) ;
1262
+
1263
+ if amount_msat <= min_liquidity_msat {
1264
+ 1.0
1265
+ } else if amount_msat >= max_liquidity_msat {
1266
+ 0.0
1267
+ } else {
1268
+ let ( numerator, denominator) = success_probability (
1269
+ amount_msat, min_liquidity_msat, max_liquidity_msat, available_capacity,
1270
+ score_params, false
1271
+ ) ;
1272
+ numerator as f64 / denominator as f64
1273
+ }
1274
+ }
1275
+
1254
1276
/// Returns the lower bound of the channel liquidity balance in this direction.
1255
1277
#[ inline( always) ]
1256
1278
fn min_liquidity_msat ( & self ) -> u64 {
@@ -1390,6 +1412,17 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreLookUp for Probabilistic
1390
1412
. saturating_add ( base_penalty_msat)
1391
1413
}
1392
1414
1415
+ fn channel_success_probability (
1416
+ & self , short_channel_id : u64 , info : & DirectedChannelInfo , usage : ChannelUsage ,
1417
+ score_params : & ProbabilisticScoringFeeParameters
1418
+ ) -> f64 {
1419
+ self . channel_liquidities
1420
+ . get ( & short_channel_id)
1421
+ . unwrap_or ( & ChannelLiquidity :: new ( Duration :: ZERO ) )
1422
+ . as_directed ( info. source ( ) , info. target ( ) , usage. effective_capacity . as_msat ( ) )
1423
+ . success_probability ( usage, score_params)
1424
+ }
1425
+
1393
1426
fn channel_balance_certainty ( & self , short_channel_id : u64 , info : & DirectedChannelInfo ) -> f64 {
1394
1427
self . channel_liquidities
1395
1428
. get ( & short_channel_id)
0 commit comments