@@ -61,7 +61,6 @@ use crate::routing::gossip::{EffectiveCapacity, NetworkGraph, NodeId};
61
61
use crate :: routing:: router:: Path ;
62
62
use crate :: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
63
63
use crate :: util:: logger:: Logger ;
64
- use crate :: util:: time:: Time ;
65
64
66
65
use crate :: prelude:: * ;
67
66
use core:: { cmp, fmt} ;
@@ -441,13 +440,6 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
441
440
}
442
441
}
443
442
444
- #[ cfg( not( feature = "no-std" ) ) ]
445
- type ConfiguredTime = crate :: util:: time:: MonotonicTime ;
446
- #[ cfg( feature = "no-std" ) ]
447
- use crate :: util:: time:: Eternity ;
448
- #[ cfg( feature = "no-std" ) ]
449
- type ConfiguredTime = Eternity ;
450
-
451
443
/// [`ScoreLookUp`] implementation using channel success probability distributions.
452
444
///
453
445
/// Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel,
@@ -484,18 +476,12 @@ type ConfiguredTime = Eternity;
484
476
/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life
485
477
/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_multiplier_msat
486
478
/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_amount_multiplier_msat
487
- pub type ProbabilisticScorer < G , L > = ProbabilisticScorerUsingTime :: < G , L , ConfiguredTime > ;
488
-
489
- /// Probabilistic [`ScoreLookUp`] implementation.
490
- ///
491
- /// This is not exported to bindings users generally all users should use the [`ProbabilisticScorer`] type alias.
492
- pub struct ProbabilisticScorerUsingTime < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time >
479
+ pub struct ProbabilisticScorer < G : Deref < Target = NetworkGraph < L > > , L : Deref >
493
480
where L :: Target : Logger {
494
481
decay_params : ProbabilisticScoringDecayParameters ,
495
482
network_graph : G ,
496
483
logger : L ,
497
484
channel_liquidities : HashMap < u64 , ChannelLiquidity > ,
498
- _unused_time : core:: marker:: PhantomData < T > ,
499
485
}
500
486
501
487
/// Parameters for configuring [`ProbabilisticScorer`].
@@ -750,7 +736,7 @@ pub struct ProbabilisticScoringDecayParameters {
750
736
///
751
737
/// Default value: 14 days
752
738
///
753
- /// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime ::historical_estimated_channel_liquidity_probabilities
739
+ /// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer ::historical_estimated_channel_liquidity_probabilities
754
740
pub historical_no_updates_half_life : Duration ,
755
741
756
742
/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds,
@@ -829,7 +815,7 @@ struct DirectedChannelLiquidity<L: Deref<Target = u64>, BRT: Deref<Target = Hist
829
815
decay_params : ProbabilisticScoringDecayParameters ,
830
816
}
831
817
832
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
818
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ProbabilisticScorer < G , L > where L :: Target : Logger {
833
819
/// Creates a new scorer using the given scoring parameters for sending payments from a node
834
820
/// through a network graph.
835
821
pub fn new ( decay_params : ProbabilisticScoringDecayParameters , network_graph : G , logger : L ) -> Self {
@@ -838,7 +824,6 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
838
824
network_graph,
839
825
logger,
840
826
channel_liquidities : HashMap :: new ( ) ,
841
- _unused_time : core:: marker:: PhantomData ,
842
827
}
843
828
}
844
829
@@ -1352,7 +1337,7 @@ DirectedChannelLiquidity<L, BRT, T> {
1352
1337
}
1353
1338
}
1354
1339
1355
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ScoreLookUp for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
1340
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ScoreLookUp for ProbabilisticScorer < G , L > where L :: Target : Logger {
1356
1341
type ScoreParams = ProbabilisticScoringFeeParameters ;
1357
1342
fn channel_penalty_msat (
1358
1343
& self , short_channel_id : u64 , source : & NodeId , target : & NodeId , usage : ChannelUsage , score_params : & ProbabilisticScoringFeeParameters
@@ -1396,7 +1381,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreLookUp for Prob
1396
1381
}
1397
1382
}
1398
1383
1399
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ScoreUpdate for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
1384
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ScoreUpdate for ProbabilisticScorer < G , L > where L :: Target : Logger {
1400
1385
fn payment_path_failed ( & mut self , path : & Path , short_channel_id : u64 , duration_since_epoch : Duration ) {
1401
1386
let amount_msat = path. final_value_msat ( ) ;
1402
1387
log_trace ! ( self . logger, "Scoring path through to SCID {} as having failed at {} msat" , short_channel_id, amount_msat) ;
@@ -1503,7 +1488,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1503
1488
}
1504
1489
1505
1490
#[ cfg( c_bindings) ]
1506
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > Score for ProbabilisticScorerUsingTime < G , L , T >
1491
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > Score for ProbabilisticScorer < G , L >
1507
1492
where L :: Target : Logger { }
1508
1493
1509
1494
#[ cfg( feature = "std" ) ]
@@ -2089,7 +2074,7 @@ mod bucketed_history {
2089
2074
}
2090
2075
use bucketed_history:: { LegacyHistoricalBucketRangeTracker , HistoricalBucketRangeTracker , HistoricalMinMaxBuckets } ;
2091
2076
2092
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > Writeable for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
2077
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > Writeable for ProbabilisticScorer < G , L > where L :: Target : Logger {
2093
2078
#[ inline]
2094
2079
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
2095
2080
write_tlv_fields ! ( w, {
@@ -2099,8 +2084,8 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> Writeable for Probab
2099
2084
}
2100
2085
}
2101
2086
2102
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time >
2103
- ReadableArgs < ( ProbabilisticScoringDecayParameters , G , L ) > for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
2087
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref >
2088
+ ReadableArgs < ( ProbabilisticScoringDecayParameters , G , L ) > for ProbabilisticScorer < G , L > where L :: Target : Logger {
2104
2089
#[ inline]
2105
2090
fn read < R : Read > (
2106
2091
r : & mut R , args : ( ProbabilisticScoringDecayParameters , G , L )
@@ -2115,7 +2100,6 @@ ReadableArgs<(ProbabilisticScoringDecayParameters, G, L)> for ProbabilisticScore
2115
2100
network_graph,
2116
2101
logger,
2117
2102
channel_liquidities,
2118
- _unused_time : core:: marker:: PhantomData ,
2119
2103
} )
2120
2104
}
2121
2105
}
@@ -2185,7 +2169,7 @@ impl Readable for ChannelLiquidity {
2185
2169
2186
2170
#[ cfg( test) ]
2187
2171
mod tests {
2188
- use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorerUsingTime } ;
2172
+ use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorer } ;
2189
2173
use crate :: blinded_path:: { BlindedHop , BlindedPath } ;
2190
2174
use crate :: util:: config:: UserConfig ;
2191
2175
use crate :: util:: time:: tests:: SinceEpoch ;
@@ -2234,9 +2218,6 @@ mod tests {
2234
2218
2235
2219
// `ProbabilisticScorer` tests
2236
2220
2237
- /// A probabilistic scorer for testing with time that can be manually advanced.
2238
- type ProbabilisticScorer < ' a > = ProbabilisticScorerUsingTime :: < & ' a NetworkGraph < & ' a TestLogger > , & ' a TestLogger , SinceEpoch > ;
2239
-
2240
2221
fn sender_privkey ( ) -> SecretKey {
2241
2222
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( )
2242
2223
}
@@ -3038,7 +3019,7 @@ mod tests {
3038
3019
3039
3020
let mut serialized_scorer = io:: Cursor :: new ( & serialized_scorer) ;
3040
3021
let deserialized_scorer =
3041
- <ProbabilisticScorer >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3022
+ <ProbabilisticScorer < _ , _ > >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3042
3023
assert_eq ! ( deserialized_scorer. channel_penalty_msat( 42 , & source, & target, usage, & params) , 300 ) ;
3043
3024
}
3044
3025
@@ -3076,7 +3057,7 @@ mod tests {
3076
3057
3077
3058
let mut serialized_scorer = io:: Cursor :: new ( & serialized_scorer) ;
3078
3059
let mut deserialized_scorer =
3079
- <ProbabilisticScorer >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3060
+ <ProbabilisticScorer < _ , _ > >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3080
3061
if !decay_before_reload {
3081
3062
SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3082
3063
scorer. decay_liquidity_certainty ( Duration :: from_secs ( 10 ) ) ;
0 commit comments