@@ -494,7 +494,8 @@ where L::Target: Logger {
494
494
decay_params : ProbabilisticScoringDecayParameters ,
495
495
network_graph : G ,
496
496
logger : L ,
497
- channel_liquidities : HashMap < u64 , ChannelLiquidity < T > > ,
497
+ channel_liquidities : HashMap < u64 , ChannelLiquidity > ,
498
+ _unused_time : core:: marker:: PhantomData < T > ,
498
499
}
499
500
500
501
/// Parameters for configuring [`ProbabilisticScorer`].
@@ -798,7 +799,7 @@ impl ProbabilisticScoringDecayParameters {
798
799
/// Direction is defined in terms of [`NodeId`] partial ordering, where the source node is the
799
800
/// first node in the ordering of the channel's counterparties. Thus, swapping the two liquidity
800
801
/// offset fields gives the opposite direction.
801
- struct ChannelLiquidity < T : Time > {
802
+ struct ChannelLiquidity {
802
803
/// Lower channel liquidity bound in terms of an offset from zero.
803
804
min_liquidity_offset_msat : u64 ,
804
805
@@ -808,23 +809,23 @@ struct ChannelLiquidity<T: Time> {
808
809
min_liquidity_offset_history : HistoricalBucketRangeTracker ,
809
810
max_liquidity_offset_history : HistoricalBucketRangeTracker ,
810
811
811
- /// Time when the liquidity bounds were last modified.
812
- last_updated : T ,
812
+ /// Time when the liquidity bounds were last modified as an offset since the unix epoch .
813
+ last_updated : Duration ,
813
814
814
- /// Time when the historical liquidity bounds were last modified.
815
- offset_history_last_updated : T ,
815
+ /// Time when the historical liquidity bounds were last modified as an offset against the unix
816
+ /// epoch.
817
+ offset_history_last_updated : Duration ,
816
818
}
817
819
818
820
/// A snapshot of [`ChannelLiquidity`] in one direction assuming a certain channel capacity and
819
821
/// decayed with a given half life.
820
- struct DirectedChannelLiquidity < L : Deref < Target = u64 > , BRT : Deref < Target = HistoricalBucketRangeTracker > , T : Time , U : Deref < Target = T > > {
822
+ struct DirectedChannelLiquidity < L : Deref < Target = u64 > , BRT : Deref < Target = HistoricalBucketRangeTracker > , T : Deref < Target = Duration > > {
821
823
min_liquidity_offset_msat : L ,
822
824
max_liquidity_offset_msat : L ,
823
825
liquidity_history : HistoricalMinMaxBuckets < BRT > ,
824
826
capacity_msat : u64 ,
825
- last_updated : U ,
826
- offset_history_last_updated : U ,
827
- now : T ,
827
+ last_updated : T ,
828
+ offset_history_last_updated : T ,
828
829
decay_params : ProbabilisticScoringDecayParameters ,
829
830
}
830
831
@@ -837,11 +838,12 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
837
838
network_graph,
838
839
logger,
839
840
channel_liquidities : HashMap :: new ( ) ,
841
+ _unused_time : core:: marker:: PhantomData ,
840
842
}
841
843
}
842
844
843
845
#[ cfg( test) ]
844
- fn with_channel ( mut self , short_channel_id : u64 , liquidity : ChannelLiquidity < T > ) -> Self {
846
+ fn with_channel ( mut self , short_channel_id : u64 , liquidity : ChannelLiquidity ) -> Self {
845
847
assert ! ( self . channel_liquidities. insert( short_channel_id, liquidity) . is_none( ) ) ;
846
848
self
847
849
}
@@ -994,24 +996,23 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
994
996
}
995
997
}
996
998
997
- impl < T : Time > ChannelLiquidity < T > {
998
- #[ inline]
999
- fn new ( ) -> Self {
999
+ impl ChannelLiquidity {
1000
+ fn new ( last_updated : Duration ) -> Self {
1000
1001
Self {
1001
1002
min_liquidity_offset_msat : 0 ,
1002
1003
max_liquidity_offset_msat : 0 ,
1003
1004
min_liquidity_offset_history : HistoricalBucketRangeTracker :: new ( ) ,
1004
1005
max_liquidity_offset_history : HistoricalBucketRangeTracker :: new ( ) ,
1005
- last_updated : T :: now ( ) ,
1006
- offset_history_last_updated : T :: now ( ) ,
1006
+ last_updated,
1007
+ offset_history_last_updated : last_updated ,
1007
1008
}
1008
1009
}
1009
1010
1010
1011
/// Returns a view of the channel liquidity directed from `source` to `target` assuming
1011
1012
/// `capacity_msat`.
1012
1013
fn as_directed (
1013
1014
& self , source : & NodeId , target : & NodeId , capacity_msat : u64 , decay_params : ProbabilisticScoringDecayParameters
1014
- ) -> DirectedChannelLiquidity < & u64 , & HistoricalBucketRangeTracker , T , & T > {
1015
+ ) -> DirectedChannelLiquidity < & u64 , & HistoricalBucketRangeTracker , & Duration > {
1015
1016
let ( min_liquidity_offset_msat, max_liquidity_offset_msat, min_liquidity_offset_history, max_liquidity_offset_history) =
1016
1017
if source < target {
1017
1018
( & self . min_liquidity_offset_msat , & self . max_liquidity_offset_msat ,
@@ -1031,7 +1032,6 @@ impl<T: Time> ChannelLiquidity<T> {
1031
1032
capacity_msat,
1032
1033
last_updated : & self . last_updated ,
1033
1034
offset_history_last_updated : & self . offset_history_last_updated ,
1034
- now : T :: now ( ) ,
1035
1035
decay_params : decay_params,
1036
1036
}
1037
1037
}
@@ -1040,7 +1040,7 @@ impl<T: Time> ChannelLiquidity<T> {
1040
1040
/// `capacity_msat`.
1041
1041
fn as_directed_mut (
1042
1042
& mut self , source : & NodeId , target : & NodeId , capacity_msat : u64 , decay_params : ProbabilisticScoringDecayParameters
1043
- ) -> DirectedChannelLiquidity < & mut u64 , & mut HistoricalBucketRangeTracker , T , & mut T > {
1043
+ ) -> DirectedChannelLiquidity < & mut u64 , & mut HistoricalBucketRangeTracker , & mut Duration > {
1044
1044
let ( min_liquidity_offset_msat, max_liquidity_offset_msat, min_liquidity_offset_history, max_liquidity_offset_history) =
1045
1045
if source < target {
1046
1046
( & mut self . min_liquidity_offset_msat , & mut self . max_liquidity_offset_msat ,
@@ -1060,7 +1060,6 @@ impl<T: Time> ChannelLiquidity<T> {
1060
1060
capacity_msat,
1061
1061
last_updated : & mut self . last_updated ,
1062
1062
offset_history_last_updated : & mut self . offset_history_last_updated ,
1063
- now : T :: now ( ) ,
1064
1063
decay_params : decay_params,
1065
1064
}
1066
1065
}
@@ -1070,7 +1069,7 @@ impl<T: Time> ChannelLiquidity<T> {
1070
1069
) -> u64 {
1071
1070
let half_life = decay_params. liquidity_offset_half_life . as_secs ( ) ;
1072
1071
if half_life != 0 {
1073
- let elapsed_time = T :: now ( ) . duration_since ( self . last_updated ) . as_secs ( ) as f64 ;
1072
+ let elapsed_time = duration_since_epoch . saturating_sub ( self . last_updated ) . as_secs ( ) as f64 ;
1074
1073
( ( offset as f64 ) * powf64 ( 0.5 , elapsed_time / ( half_life as f64 ) ) ) as u64
1075
1074
} else {
1076
1075
0
@@ -1159,7 +1158,8 @@ fn success_probability(
1159
1158
( numerator, denominator)
1160
1159
}
1161
1160
1162
- impl < L : Deref < Target = u64 > , BRT : Deref < Target = HistoricalBucketRangeTracker > , T : Time , U : Deref < Target = T > > DirectedChannelLiquidity < L , BRT , T , U > {
1161
+ impl < L : Deref < Target = u64 > , BRT : Deref < Target = HistoricalBucketRangeTracker > , T : Deref < Target = Duration > >
1162
+ DirectedChannelLiquidity < L , BRT , T > {
1163
1163
/// Returns a liquidity penalty for routing the given HTLC `amount_msat` through the channel in
1164
1164
/// this direction.
1165
1165
fn penalty_msat ( & self , amount_msat : u64 , score_params : & ProbabilisticScoringFeeParameters ) -> u64 {
@@ -1267,7 +1267,8 @@ impl<L: Deref<Target = u64>, BRT: Deref<Target = HistoricalBucketRangeTracker>,
1267
1267
}
1268
1268
}
1269
1269
1270
- impl < L : DerefMut < Target = u64 > , BRT : DerefMut < Target = HistoricalBucketRangeTracker > , T : Time , U : DerefMut < Target = T > > DirectedChannelLiquidity < L , BRT , T , U > {
1270
+ impl < L : DerefMut < Target = u64 > , BRT : DerefMut < Target = HistoricalBucketRangeTracker > , T : DerefMut < Target = Duration > >
1271
+ DirectedChannelLiquidity < L , BRT , T > {
1271
1272
/// Adjusts the channel liquidity balance bounds when failing to route `amount_msat`.
1272
1273
fn failed_at_channel < Log : Deref > (
1273
1274
& mut self , amount_msat : u64 , duration_since_epoch : Duration , chan_descr : fmt:: Arguments , logger : & Log
@@ -1313,7 +1314,9 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1313
1314
/// state"), we allow the caller to set an offset applied to our liquidity bounds which
1314
1315
/// represents the amount of the successful payment we just made.
1315
1316
fn update_history_buckets ( & mut self , bucket_offset_msat : u64 , duration_since_epoch : Duration ) {
1316
- let half_lives = self . now . duration_since ( * self . offset_history_last_updated ) . as_secs ( )
1317
+ let half_lives =
1318
+ duration_since_epoch. checked_sub ( * self . offset_history_last_updated )
1319
+ . unwrap_or ( Duration :: ZERO ) . as_secs ( )
1317
1320
. checked_div ( self . decay_params . historical_no_updates_half_life . as_secs ( ) )
1318
1321
. map ( |v| v. try_into ( ) . unwrap_or ( u32:: max_value ( ) ) ) . unwrap_or ( u32:: max_value ( ) ) ;
1319
1322
self . liquidity_history . min_liquidity_offset_history . time_decay_data ( half_lives) ;
@@ -1327,29 +1330,25 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1327
1330
self . liquidity_history . max_liquidity_offset_history . track_datapoint (
1328
1331
max_liquidity_offset_msat. saturating_sub ( bucket_offset_msat) , self . capacity_msat
1329
1332
) ;
1330
- * self . offset_history_last_updated = self . now ;
1333
+ * self . offset_history_last_updated = duration_since_epoch ;
1331
1334
}
1332
1335
1333
1336
/// Adjusts the lower bound of the channel liquidity balance in this direction.
1334
1337
fn set_min_liquidity_msat ( & mut self , amount_msat : u64 , duration_since_epoch : Duration ) {
1335
1338
* self . min_liquidity_offset_msat = amount_msat;
1336
- * self . max_liquidity_offset_msat = if amount_msat > self . max_liquidity_msat ( ) {
1337
- 0
1338
- } else {
1339
- self . decayed_offset_msat ( * self . max_liquidity_offset_msat )
1340
- } ;
1341
- * self . last_updated = self . now ;
1339
+ if amount_msat > self . max_liquidity_msat ( ) {
1340
+ * self . max_liquidity_offset_msat = 0 ;
1341
+ }
1342
+ * self . last_updated = duration_since_epoch;
1342
1343
}
1343
1344
1344
1345
/// Adjusts the upper bound of the channel liquidity balance in this direction.
1345
1346
fn set_max_liquidity_msat ( & mut self , amount_msat : u64 , duration_since_epoch : Duration ) {
1346
1347
* self . max_liquidity_offset_msat = self . capacity_msat . checked_sub ( amount_msat) . unwrap_or ( 0 ) ;
1347
- * self . min_liquidity_offset_msat = if amount_msat < self . min_liquidity_msat ( ) {
1348
- 0
1349
- } else {
1350
- self . decayed_offset_msat ( * self . min_liquidity_offset_msat )
1351
- } ;
1352
- * self . last_updated = self . now ;
1348
+ if amount_msat < * self . min_liquidity_offset_msat {
1349
+ * self . min_liquidity_offset_msat = 0 ;
1350
+ }
1351
+ * self . last_updated = duration_since_epoch;
1353
1352
}
1354
1353
}
1355
1354
@@ -1389,7 +1388,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreLookUp for Prob
1389
1388
let capacity_msat = usage. effective_capacity . as_msat ( ) ;
1390
1389
self . channel_liquidities
1391
1390
. get ( & short_channel_id)
1392
- . unwrap_or ( & ChannelLiquidity :: new ( ) )
1391
+ . unwrap_or ( & ChannelLiquidity :: new ( Duration :: ZERO ) )
1393
1392
. as_directed ( source, target, capacity_msat, self . decay_params )
1394
1393
. penalty_msat ( amount_msat, score_params)
1395
1394
. saturating_add ( anti_probing_penalty_msat)
@@ -1419,14 +1418,14 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1419
1418
if at_failed_channel {
1420
1419
self . channel_liquidities
1421
1420
. entry ( hop. short_channel_id )
1422
- . or_insert_with ( ChannelLiquidity :: new)
1421
+ . or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch ) )
1423
1422
. as_directed_mut ( source, & target, capacity_msat, self . decay_params )
1424
1423
. failed_at_channel ( amount_msat, duration_since_epoch,
1425
1424
format_args ! ( "SCID {}, towards {:?}" , hop. short_channel_id, target) , & self . logger ) ;
1426
1425
} else {
1427
1426
self . channel_liquidities
1428
1427
. entry ( hop. short_channel_id )
1429
- . or_insert_with ( ChannelLiquidity :: new)
1428
+ . or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch ) )
1430
1429
. as_directed_mut ( source, & target, capacity_msat, self . decay_params )
1431
1430
. failed_downstream ( amount_msat, duration_since_epoch,
1432
1431
format_args ! ( "SCID {}, towards {:?}" , hop. short_channel_id, target) , & self . logger ) ;
@@ -1455,7 +1454,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1455
1454
let capacity_msat = channel. effective_capacity ( ) . as_msat ( ) ;
1456
1455
self . channel_liquidities
1457
1456
. entry ( hop. short_channel_id )
1458
- . or_insert_with ( ChannelLiquidity :: new)
1457
+ . or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch ) )
1459
1458
. as_directed_mut ( source, & target, capacity_msat, self . decay_params )
1460
1459
. successful ( amount_msat, duration_since_epoch,
1461
1460
format_args ! ( "SCID {}, towards {:?}" , hop. short_channel_id, target) , & self . logger ) ;
@@ -1481,10 +1480,10 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1481
1480
liquidity. decayed_offset ( liquidity. min_liquidity_offset_msat , duration_since_epoch, decay_params) ;
1482
1481
liquidity. max_liquidity_offset_msat =
1483
1482
liquidity. decayed_offset ( liquidity. max_liquidity_offset_msat , duration_since_epoch, decay_params) ;
1484
- liquidity. last_updated = T :: now ( ) ;
1483
+ liquidity. last_updated = duration_since_epoch ;
1485
1484
1486
1485
let elapsed_time =
1487
- T :: now ( ) . duration_since ( liquidity. offset_history_last_updated ) ;
1486
+ duration_since_epoch . saturating_sub ( liquidity. offset_history_last_updated ) ;
1488
1487
if elapsed_time > decay_params. historical_no_updates_half_life {
1489
1488
let half_life = decay_params. historical_no_updates_half_life . as_secs ( ) as f64 ;
1490
1489
let divisor = powf64 ( 2048.0 , ( elapsed_time. as_secs ( ) as f64 ) / half_life) as u64 ;
@@ -1494,7 +1493,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ScoreUpdate for Prob
1494
1493
for bucket in liquidity. max_liquidity_offset_history . buckets . iter_mut ( ) {
1495
1494
* bucket = ( ( * bucket as u64 ) * 1024 / divisor) as u16 ;
1496
1495
}
1497
- liquidity. offset_history_last_updated = T :: now ( ) ;
1496
+ liquidity. offset_history_last_updated = duration_since_epoch ;
1498
1497
}
1499
1498
liquidity. min_liquidity_offset_msat != 0 || liquidity. max_liquidity_offset_msat != 0 ||
1500
1499
liquidity. min_liquidity_offset_history . buckets != [ 0 ; 32 ] ||
@@ -2116,31 +2115,29 @@ ReadableArgs<(ProbabilisticScoringDecayParameters, G, L)> for ProbabilisticScore
2116
2115
network_graph,
2117
2116
logger,
2118
2117
channel_liquidities,
2118
+ _unused_time : core:: marker:: PhantomData ,
2119
2119
} )
2120
2120
}
2121
2121
}
2122
2122
2123
- impl < T : Time > Writeable for ChannelLiquidity < T > {
2123
+ impl Writeable for ChannelLiquidity {
2124
2124
#[ inline]
2125
2125
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
2126
- let offset_history_duration_since_epoch =
2127
- T :: duration_since_epoch ( ) - self . offset_history_last_updated . elapsed ( ) ;
2128
- let duration_since_epoch = T :: duration_since_epoch ( ) - self . last_updated . elapsed ( ) ;
2129
2126
write_tlv_fields ! ( w, {
2130
2127
( 0 , self . min_liquidity_offset_msat, required) ,
2131
2128
// 1 was the min_liquidity_offset_history in octile form
2132
2129
( 2 , self . max_liquidity_offset_msat, required) ,
2133
2130
// 3 was the max_liquidity_offset_history in octile form
2134
- ( 4 , duration_since_epoch , required) ,
2131
+ ( 4 , self . last_updated , required) ,
2135
2132
( 5 , Some ( self . min_liquidity_offset_history) , option) ,
2136
2133
( 7 , Some ( self . max_liquidity_offset_history) , option) ,
2137
- ( 9 , offset_history_duration_since_epoch , required) ,
2134
+ ( 9 , self . offset_history_last_updated , required) ,
2138
2135
} ) ;
2139
2136
Ok ( ( ) )
2140
2137
}
2141
2138
}
2142
2139
2143
- impl < T : Time > Readable for ChannelLiquidity < T > {
2140
+ impl Readable for ChannelLiquidity {
2144
2141
#[ inline]
2145
2142
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
2146
2143
let mut min_liquidity_offset_msat = 0 ;
@@ -2149,37 +2146,18 @@ impl<T: Time> Readable for ChannelLiquidity<T> {
2149
2146
let mut legacy_max_liq_offset_history: Option < LegacyHistoricalBucketRangeTracker > = None ;
2150
2147
let mut min_liquidity_offset_history: Option < HistoricalBucketRangeTracker > = None ;
2151
2148
let mut max_liquidity_offset_history: Option < HistoricalBucketRangeTracker > = None ;
2152
- let mut duration_since_epoch = Duration :: from_secs ( 0 ) ;
2153
- let mut offset_history_duration_since_epoch = None ;
2149
+ let mut last_updated = Duration :: from_secs ( 0 ) ;
2150
+ let mut offset_history_last_updated = None ;
2154
2151
read_tlv_fields ! ( r, {
2155
2152
( 0 , min_liquidity_offset_msat, required) ,
2156
2153
( 1 , legacy_min_liq_offset_history, option) ,
2157
2154
( 2 , max_liquidity_offset_msat, required) ,
2158
2155
( 3 , legacy_max_liq_offset_history, option) ,
2159
- ( 4 , duration_since_epoch , required) ,
2156
+ ( 4 , last_updated , required) ,
2160
2157
( 5 , min_liquidity_offset_history, option) ,
2161
2158
( 7 , max_liquidity_offset_history, option) ,
2162
- ( 9 , offset_history_duration_since_epoch , option) ,
2159
+ ( 9 , offset_history_last_updated , option) ,
2163
2160
} ) ;
2164
- // On rust prior to 1.60 `Instant::duration_since` will panic if time goes backwards.
2165
- // We write `last_updated` as wallclock time even though its ultimately an `Instant` (which
2166
- // is a time from a monotonic clock usually represented as an offset against boot time).
2167
- // Thus, we have to construct an `Instant` by subtracting the difference in wallclock time
2168
- // from the one that was written. However, because `Instant` can panic if we construct one
2169
- // in the future, we must handle wallclock time jumping backwards, which we do by simply
2170
- // using `Instant::now()` in that case.
2171
- let wall_clock_now = T :: duration_since_epoch ( ) ;
2172
- let now = T :: now ( ) ;
2173
- let last_updated = if wall_clock_now > duration_since_epoch {
2174
- now - ( wall_clock_now - duration_since_epoch)
2175
- } else { now } ;
2176
-
2177
- let offset_history_duration_since_epoch =
2178
- offset_history_duration_since_epoch. unwrap_or ( duration_since_epoch) ;
2179
- let offset_history_last_updated = if wall_clock_now > offset_history_duration_since_epoch {
2180
- now - ( wall_clock_now - duration_since_epoch)
2181
- } else { now } ;
2182
-
2183
2161
if min_liquidity_offset_history. is_none ( ) {
2184
2162
if let Some ( legacy_buckets) = legacy_min_liq_offset_history {
2185
2163
min_liquidity_offset_history = Some ( legacy_buckets. into_current ( ) ) ;
@@ -2200,7 +2178,7 @@ impl<T: Time> Readable for ChannelLiquidity<T> {
2200
2178
min_liquidity_offset_history : min_liquidity_offset_history. unwrap ( ) ,
2201
2179
max_liquidity_offset_history : max_liquidity_offset_history. unwrap ( ) ,
2202
2180
last_updated,
2203
- offset_history_last_updated,
2181
+ offset_history_last_updated : offset_history_last_updated . unwrap_or ( last_updated ) ,
2204
2182
} )
2205
2183
}
2206
2184
}
@@ -2210,7 +2188,6 @@ mod tests {
2210
2188
use super :: { ChannelLiquidity , HistoricalBucketRangeTracker , ProbabilisticScoringFeeParameters , ProbabilisticScoringDecayParameters , ProbabilisticScorerUsingTime } ;
2211
2189
use crate :: blinded_path:: { BlindedHop , BlindedPath } ;
2212
2190
use crate :: util:: config:: UserConfig ;
2213
- use crate :: util:: time:: Time ;
2214
2191
use crate :: util:: time:: tests:: SinceEpoch ;
2215
2192
2216
2193
use crate :: ln:: channelmanager;
@@ -2379,8 +2356,8 @@ mod tests {
2379
2356
#[ test]
2380
2357
fn liquidity_bounds_directed_from_lowest_node_id ( ) {
2381
2358
let logger = TestLogger :: new ( ) ;
2382
- let last_updated = SinceEpoch :: now ( ) ;
2383
- let offset_history_last_updated = SinceEpoch :: now ( ) ;
2359
+ let last_updated = Duration :: ZERO ;
2360
+ let offset_history_last_updated = Duration :: ZERO ;
2384
2361
let network_graph = network_graph ( & logger) ;
2385
2362
let decay_params = ProbabilisticScoringDecayParameters :: default ( ) ;
2386
2363
let mut scorer = ProbabilisticScorer :: new ( decay_params, & network_graph, & logger)
@@ -2460,8 +2437,8 @@ mod tests {
2460
2437
#[ test]
2461
2438
fn resets_liquidity_upper_bound_when_crossed_by_lower_bound ( ) {
2462
2439
let logger = TestLogger :: new ( ) ;
2463
- let last_updated = SinceEpoch :: now ( ) ;
2464
- let offset_history_last_updated = SinceEpoch :: now ( ) ;
2440
+ let last_updated = Duration :: ZERO ;
2441
+ let offset_history_last_updated = Duration :: ZERO ;
2465
2442
let network_graph = network_graph ( & logger) ;
2466
2443
let decay_params = ProbabilisticScoringDecayParameters :: default ( ) ;
2467
2444
let mut scorer = ProbabilisticScorer :: new ( decay_params, & network_graph, & logger)
@@ -2521,8 +2498,8 @@ mod tests {
2521
2498
#[ test]
2522
2499
fn resets_liquidity_lower_bound_when_crossed_by_upper_bound ( ) {
2523
2500
let logger = TestLogger :: new ( ) ;
2524
- let last_updated = SinceEpoch :: now ( ) ;
2525
- let offset_history_last_updated = SinceEpoch :: now ( ) ;
2501
+ let last_updated = Duration :: ZERO ;
2502
+ let offset_history_last_updated = Duration :: ZERO ;
2526
2503
let network_graph = network_graph ( & logger) ;
2527
2504
let decay_params = ProbabilisticScoringDecayParameters :: default ( ) ;
2528
2505
let mut scorer = ProbabilisticScorer :: new ( decay_params, & network_graph, & logger)
@@ -2628,8 +2605,8 @@ mod tests {
2628
2605
#[ test]
2629
2606
fn constant_penalty_outside_liquidity_bounds ( ) {
2630
2607
let logger = TestLogger :: new ( ) ;
2631
- let last_updated = SinceEpoch :: now ( ) ;
2632
- let offset_history_last_updated = SinceEpoch :: now ( ) ;
2608
+ let last_updated = Duration :: ZERO ;
2609
+ let offset_history_last_updated = Duration :: ZERO ;
2633
2610
let network_graph = network_graph ( & logger) ;
2634
2611
let params = ProbabilisticScoringFeeParameters {
2635
2612
liquidity_penalty_multiplier_msat : 1_000 ,
0 commit comments