@@ -61,7 +61,6 @@ use crate::routing::gossip::{EffectiveCapacity, NetworkGraph, NodeId};
61
61
use crate :: routing:: router:: { Path , CandidateRouteHop } ;
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} ;
@@ -440,13 +439,6 @@ impl ReadableArgs<u64> for FixedPenaltyScorer {
440
439
}
441
440
}
442
441
443
- #[ cfg( not( feature = "no-std" ) ) ]
444
- type ConfiguredTime = crate :: util:: time:: MonotonicTime ;
445
- #[ cfg( feature = "no-std" ) ]
446
- use crate :: util:: time:: Eternity ;
447
- #[ cfg( feature = "no-std" ) ]
448
- type ConfiguredTime = Eternity ;
449
-
450
442
/// [`ScoreLookUp`] implementation using channel success probability distributions.
451
443
///
452
444
/// Channels are tracked with upper and lower liquidity bounds - when an HTLC fails at a channel,
@@ -483,18 +475,12 @@ type ConfiguredTime = Eternity;
483
475
/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life
484
476
/// [`historical_liquidity_penalty_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_multiplier_msat
485
477
/// [`historical_liquidity_penalty_amount_multiplier_msat`]: ProbabilisticScoringFeeParameters::historical_liquidity_penalty_amount_multiplier_msat
486
- pub type ProbabilisticScorer < G , L > = ProbabilisticScorerUsingTime :: < G , L , ConfiguredTime > ;
487
-
488
- /// Probabilistic [`ScoreLookUp`] implementation.
489
- ///
490
- /// This is not exported to bindings users generally all users should use the [`ProbabilisticScorer`] type alias.
491
- pub struct ProbabilisticScorerUsingTime < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time >
478
+ pub struct ProbabilisticScorer < G : Deref < Target = NetworkGraph < L > > , L : Deref >
492
479
where L :: Target : Logger {
493
480
decay_params : ProbabilisticScoringDecayParameters ,
494
481
network_graph : G ,
495
482
logger : L ,
496
483
channel_liquidities : HashMap < u64 , ChannelLiquidity > ,
497
- _unused_time : core:: marker:: PhantomData < T > ,
498
484
}
499
485
500
486
/// Parameters for configuring [`ProbabilisticScorer`].
@@ -749,7 +735,7 @@ pub struct ProbabilisticScoringDecayParameters {
749
735
///
750
736
/// Default value: 14 days
751
737
///
752
- /// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorerUsingTime ::historical_estimated_channel_liquidity_probabilities
738
+ /// [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer ::historical_estimated_channel_liquidity_probabilities
753
739
pub historical_no_updates_half_life : Duration ,
754
740
755
741
/// Whenever this amount of time elapses since the last update to a channel's liquidity bounds,
@@ -827,7 +813,7 @@ struct DirectedChannelLiquidity<L: Deref<Target = u64>, BRT: Deref<Target = Hist
827
813
decay_params : ProbabilisticScoringDecayParameters ,
828
814
}
829
815
830
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
816
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ProbabilisticScorer < G , L > where L :: Target : Logger {
831
817
/// Creates a new scorer using the given scoring parameters for sending payments from a node
832
818
/// through a network graph.
833
819
pub fn new ( decay_params : ProbabilisticScoringDecayParameters , network_graph : G , logger : L ) -> Self {
@@ -836,7 +822,6 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
836
822
network_graph,
837
823
logger,
838
824
channel_liquidities : HashMap :: new ( ) ,
839
- _unused_time : core:: marker:: PhantomData ,
840
825
}
841
826
}
842
827
@@ -1351,7 +1336,7 @@ DirectedChannelLiquidity<L, BRT, T> {
1351
1336
}
1352
1337
}
1353
1338
1354
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ScoreLookUp for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
1339
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ScoreLookUp for ProbabilisticScorer < G , L > where L :: Target : Logger {
1355
1340
type ScoreParams = ProbabilisticScoringFeeParameters ;
1356
1341
fn channel_penalty_msat (
1357
1342
& self , candidate : & CandidateRouteHop , usage : ChannelUsage , score_params : & ProbabilisticScoringFeeParameters
@@ -1402,7 +1387,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreLookUp for Prob
1402
1387
}
1403
1388
}
1404
1389
1405
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > ScoreUpdate for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
1390
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > ScoreUpdate for ProbabilisticScorer < G , L > where L :: Target : Logger {
1406
1391
fn payment_path_failed ( & mut self , path : & Path , short_channel_id : u64 , duration_since_epoch : Duration ) {
1407
1392
let amount_msat = path. final_value_msat ( ) ;
1408
1393
log_trace ! ( self . logger, "Scoring path through to SCID {} as having failed at {} msat" , short_channel_id, amount_msat) ;
@@ -1511,7 +1496,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1511
1496
}
1512
1497
1513
1498
#[ cfg( c_bindings) ]
1514
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > Score for ProbabilisticScorerUsingTime < G , L , T >
1499
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > Score for ProbabilisticScorer < G , L >
1515
1500
where L :: Target : Logger { }
1516
1501
1517
1502
#[ cfg( feature = "std" ) ]
@@ -2097,7 +2082,7 @@ mod bucketed_history {
2097
2082
}
2098
2083
use bucketed_history:: { LegacyHistoricalBucketRangeTracker , HistoricalBucketRangeTracker , HistoricalMinMaxBuckets } ;
2099
2084
2100
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time > Writeable for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
2085
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref > Writeable for ProbabilisticScorer < G , L > where L :: Target : Logger {
2101
2086
#[ inline]
2102
2087
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
2103
2088
write_tlv_fields ! ( w, {
@@ -2107,8 +2092,8 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> Writeable for Probab
2107
2092
}
2108
2093
}
2109
2094
2110
- impl < G : Deref < Target = NetworkGraph < L > > , L : Deref , T : Time >
2111
- ReadableArgs < ( ProbabilisticScoringDecayParameters , G , L ) > for ProbabilisticScorerUsingTime < G , L , T > where L :: Target : Logger {
2095
+ impl < G : Deref < Target = NetworkGraph < L > > , L : Deref >
2096
+ ReadableArgs < ( ProbabilisticScoringDecayParameters , G , L ) > for ProbabilisticScorer < G , L > where L :: Target : Logger {
2112
2097
#[ inline]
2113
2098
fn read < R : Read > (
2114
2099
r : & mut R , args : ( ProbabilisticScoringDecayParameters , G , L )
@@ -2123,7 +2108,6 @@ ReadableArgs<(ProbabilisticScoringDecayParameters, G, L)> for ProbabilisticScore
2123
2108
network_graph,
2124
2109
logger,
2125
2110
channel_liquidities,
2126
- _unused_time : core:: marker:: PhantomData ,
2127
2111
} )
2128
2112
}
2129
2113
}
@@ -2194,7 +2178,7 @@ impl Readable for ChannelLiquidity {
2194
2178
2195
2179
#[ cfg( test) ]
2196
2180
mod tests {
2197
- use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorerUsingTime } ;
2181
+ use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorer } ;
2198
2182
use crate :: blinded_path:: { BlindedHop , BlindedPath } ;
2199
2183
use crate :: util:: config:: UserConfig ;
2200
2184
use crate :: util:: time:: tests:: SinceEpoch ;
@@ -2243,9 +2227,6 @@ mod tests {
2243
2227
2244
2228
// `ProbabilisticScorer` tests
2245
2229
2246
- /// A probabilistic scorer for testing with time that can be manually advanced.
2247
- type ProbabilisticScorer < ' a > = ProbabilisticScorerUsingTime :: < & ' a NetworkGraph < & ' a TestLogger > , & ' a TestLogger , SinceEpoch > ;
2248
-
2249
2230
fn sender_privkey ( ) -> SecretKey {
2250
2231
SecretKey :: from_slice ( & [ 41 ; 32 ] ) . unwrap ( )
2251
2232
}
@@ -3138,7 +3119,7 @@ mod tests {
3138
3119
3139
3120
let mut serialized_scorer = io:: Cursor :: new ( & serialized_scorer) ;
3140
3121
let deserialized_scorer =
3141
- <ProbabilisticScorer >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3122
+ <ProbabilisticScorer < _ , _ > >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3142
3123
assert_eq ! ( deserialized_scorer. channel_penalty_msat( & candidate, usage, & params) , 300 ) ;
3143
3124
}
3144
3125
@@ -3181,7 +3162,7 @@ mod tests {
3181
3162
3182
3163
let mut serialized_scorer = io:: Cursor :: new ( & serialized_scorer) ;
3183
3164
let mut deserialized_scorer =
3184
- <ProbabilisticScorer >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3165
+ <ProbabilisticScorer < _ , _ > >:: read ( & mut serialized_scorer, ( decay_params, & network_graph, & logger) ) . unwrap ( ) ;
3185
3166
if !decay_before_reload {
3186
3167
SinceEpoch :: advance ( Duration :: from_secs ( 10 ) ) ;
3187
3168
scorer. time_passed ( Duration :: from_secs ( 10 ) ) ;
0 commit comments