@@ -807,7 +807,6 @@ struct DirectedChannelLiquidity<L: Deref<Target = u64>, BRT: Deref<Target = Hist
807807	capacity_msat :  u64 , 
808808	last_updated :  T , 
809809	offset_history_last_updated :  T , 
810- 	decay_params :  ProbabilisticScoringDecayParameters , 
811810} 
812811
813812impl < G :  Deref < Target  = NetworkGraph < L > > ,  L :  Deref >  ProbabilisticScorer < G ,  L >  where  L :: Target :  Logger  { 
@@ -839,7 +838,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
839838				let  log_direction = |source,  target| { 
840839					if  let  Some ( ( directed_info,  _) )  = chan_debug. as_directed_to ( target)  { 
841840						let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
842- 						let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
841+ 						let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
843842
844843						let  min_buckets = & dir_liq. liquidity_history . min_liquidity_offset_history . buckets ; 
845844						let  max_buckets = & dir_liq. liquidity_history . max_liquidity_offset_history . buckets ; 
@@ -891,7 +890,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
891890			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
892891				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
893892					let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
894- 					let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
893+ 					let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
895894					return  Some ( ( dir_liq. min_liquidity_msat ( ) ,  dir_liq. max_liquidity_msat ( ) ) ) ; 
896895				} 
897896			} 
@@ -933,7 +932,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
933932			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
934933				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
935934					let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
936- 					let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
935+ 					let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
937936
938937					let  min_buckets = dir_liq. liquidity_history . min_liquidity_offset_history . buckets ; 
939938					let  mut  max_buckets = dir_liq. liquidity_history . max_liquidity_offset_history . buckets ; 
@@ -964,7 +963,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
964963			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
965964				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
966965					let  capacity_msat = directed_info. effective_capacity ( ) . as_msat ( ) ; 
967- 					let  dir_liq = liq. as_directed ( source,  target,  capacity_msat,   self . decay_params ) ; 
966+ 					let  dir_liq = liq. as_directed ( source,  target,  capacity_msat) ; 
968967
969968					return  dir_liq. liquidity_history . calculate_success_probability_times_billion ( 
970969						& params,  amount_msat,  capacity_msat
@@ -991,7 +990,7 @@ impl ChannelLiquidity {
991990	/// Returns a view of the channel liquidity directed from `source` to `target` assuming 
992991/// `capacity_msat`. 
993992fn  as_directed ( 
994- 		& self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 ,   decay_params :   ProbabilisticScoringDecayParameters 
993+ 		& self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 , 
995994	)  -> DirectedChannelLiquidity < & u64 ,  & HistoricalBucketRangeTracker ,  & Duration >  { 
996995		let  ( min_liquidity_offset_msat,  max_liquidity_offset_msat,  min_liquidity_offset_history,  max_liquidity_offset_history)  =
997996			if  source < target { 
@@ -1012,14 +1011,13 @@ impl ChannelLiquidity {
10121011			capacity_msat, 
10131012			last_updated :  & self . last_updated , 
10141013			offset_history_last_updated :  & self . offset_history_last_updated , 
1015- 			decay_params :  decay_params, 
10161014		} 
10171015	} 
10181016
10191017	/// Returns a mutable view of the channel liquidity directed from `source` to `target` assuming 
10201018/// `capacity_msat`. 
10211019fn  as_directed_mut ( 
1022- 		& mut  self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 ,   decay_params :   ProbabilisticScoringDecayParameters 
1020+ 		& mut  self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 , 
10231021	)  -> DirectedChannelLiquidity < & mut  u64 ,  & mut  HistoricalBucketRangeTracker ,  & mut  Duration >  { 
10241022		let  ( min_liquidity_offset_msat,  max_liquidity_offset_msat,  min_liquidity_offset_history,  max_liquidity_offset_history)  =
10251023			if  source < target { 
@@ -1040,7 +1038,6 @@ impl ChannelLiquidity {
10401038			capacity_msat, 
10411039			last_updated :  & mut  self . last_updated , 
10421040			offset_history_last_updated :  & mut  self . offset_history_last_updated , 
1043- 			decay_params :  decay_params, 
10441041		} 
10451042	} 
10461043
@@ -1290,14 +1287,6 @@ DirectedChannelLiquidity<L, BRT, T> {
12901287/// state"), we allow the caller to set an offset applied to our liquidity bounds which 
12911288/// represents the amount of the successful payment we just made. 
12921289fn  update_history_buckets ( & mut  self ,  bucket_offset_msat :  u64 ,  duration_since_epoch :  Duration )  { 
1293- 		let  half_lives =
1294- 			duration_since_epoch. checked_sub ( * self . offset_history_last_updated ) 
1295- 			. unwrap_or ( Duration :: ZERO ) . as_secs ( ) 
1296- 			. checked_div ( self . decay_params . historical_no_updates_half_life . as_secs ( ) ) 
1297- 			. map ( |v| v. try_into ( ) . unwrap_or ( u32:: max_value ( ) ) ) . unwrap_or ( u32:: max_value ( ) ) ; 
1298- 		self . liquidity_history . min_liquidity_offset_history . time_decay_data ( half_lives) ; 
1299- 		self . liquidity_history . max_liquidity_offset_history . time_decay_data ( half_lives) ; 
1300- 
13011290		self . liquidity_history . min_liquidity_offset_history . track_datapoint ( 
13021291			* self . min_liquidity_offset_msat  + bucket_offset_msat,  self . capacity_msat 
13031292		) ; 
@@ -1363,7 +1352,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreLookUp for Probabilistic
13631352		self . channel_liquidities 
13641353			. get ( & short_channel_id) 
13651354			. unwrap_or ( & ChannelLiquidity :: new ( Duration :: ZERO ) ) 
1366- 			. as_directed ( source,  target,  capacity_msat,   self . decay_params ) 
1355+ 			. as_directed ( source,  target,  capacity_msat) 
13671356			. penalty_msat ( amount_msat,  score_params) 
13681357			. saturating_add ( anti_probing_penalty_msat) 
13691358			. saturating_add ( base_penalty_msat) 
@@ -1393,14 +1382,14 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreUpdate for Probabilistic
13931382					self . channel_liquidities 
13941383						. entry ( hop. short_channel_id ) 
13951384						. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1396- 						. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1385+ 						. as_directed_mut ( source,  & target,  capacity_msat) 
13971386						. failed_at_channel ( amount_msat,  duration_since_epoch, 
13981387							format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
13991388				}  else  { 
14001389					self . channel_liquidities 
14011390						. entry ( hop. short_channel_id ) 
14021391						. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1403- 						. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1392+ 						. as_directed_mut ( source,  & target,  capacity_msat) 
14041393						. failed_downstream ( amount_msat,  duration_since_epoch, 
14051394							format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
14061395				} 
@@ -1429,7 +1418,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreUpdate for Probabilistic
14291418				self . channel_liquidities 
14301419					. entry ( hop. short_channel_id ) 
14311420					. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1432- 					. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1421+ 					. as_directed_mut ( source,  & target,  capacity_msat) 
14331422					. successful ( amount_msat,  duration_since_epoch, 
14341423						format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
14351424			}  else  { 
@@ -1951,14 +1940,6 @@ mod bucketed_history {
19511940				self . buckets [ bucket]  = self . buckets [ bucket] . saturating_add ( BUCKET_FIXED_POINT_ONE ) ; 
19521941			} 
19531942		} 
1954- 		/// Decay all buckets by the given number of half-lives. Used to more aggressively remove old 
1955- /// datapoints as we receive newer information. 
1956- #[ inline]  
1957- 		pub ( super )  fn  time_decay_data ( & mut  self ,  half_lives :  u32 )  { 
1958- 			for  e in  self . buckets . iter_mut ( )  { 
1959- 				* e = e. checked_shr ( half_lives) . unwrap_or ( 0 ) ; 
1960- 			} 
1961- 		} 
19621943	} 
19631944
19641945	impl_writeable_tlv_based ! ( HistoricalBucketRangeTracker ,  {  ( 0 ,  buckets,  required)  } ) ; 
@@ -2354,52 +2335,52 @@ mod tests {
23542335		// Update minimum liquidity. 
23552336
23562337		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2357- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2338+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23582339		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23592340		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23602341
23612342		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2362- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2343+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23632344		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23642345		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23652346
23662347		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2367- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2348+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
23682349			. set_min_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
23692350
23702351		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2371- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2352+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23722353		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
23732354		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23742355
23752356		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2376- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2357+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23772358		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23782359		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
23792360
23802361		// Update maximum liquidity. 
23812362
23822363		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2383- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2364+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
23842365		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23852366		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23862367
23872368		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2388- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2369+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
23892370		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23902371		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23912372
23922373		scorer. channel_liquidities . get_mut ( & 43 ) . unwrap ( ) 
2393- 			. as_directed_mut ( & target,  & recipient,  1_000 ,  decay_params ) 
2374+ 			. as_directed_mut ( & target,  & recipient,  1_000 ) 
23942375			. set_max_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
23952376
23962377		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2397- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2378+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
23982379		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
23992380		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  200 ) ; 
24002381
24012382		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2402- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2383+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
24032384		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  800 ) ; 
24042385		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1000 ) ; 
24052386	} 
@@ -2425,42 +2406,42 @@ mod tests {
24252406
24262407		// Check initial bounds. 
24272408		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2428- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2409+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24292410		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24302411		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24312412
24322413		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2433- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2414+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24342415		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
24352416		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24362417
24372418		// Reset from source to target. 
24382419		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2439- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2420+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
24402421			. set_min_liquidity_msat ( 900 ,  Duration :: ZERO ) ; 
24412422
24422423		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2443- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2424+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24442425		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  900 ) ; 
24452426		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24462427
24472428		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2448- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2429+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24492430		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24502431		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  100 ) ; 
24512432
24522433		// Reset from target to source. 
24532434		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2454- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2435+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
24552436			. set_min_liquidity_msat ( 400 ,  Duration :: ZERO ) ; 
24562437
24572438		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2458- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2439+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24592440		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24602441		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24612442
24622443		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2463- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2444+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24642445		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24652446		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24662447	} 
@@ -2486,42 +2467,42 @@ mod tests {
24862467
24872468		// Check initial bounds. 
24882469		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2489- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2470+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24902471		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24912472		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24922473
24932474		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2494- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2475+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24952476		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
24962477		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24972478
24982479		// Reset from source to target. 
24992480		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2500- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2481+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
25012482			. set_max_liquidity_msat ( 300 ,  Duration :: ZERO ) ; 
25022483
25032484		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2504- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2485+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25052486		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25062487		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
25072488
25082489		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2509- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2490+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25102491		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
25112492		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25122493
25132494		// Reset from target to source. 
25142495		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2515- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2496+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
25162497			. set_max_liquidity_msat ( 600 ,  Duration :: ZERO ) ; 
25172498
25182499		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2519- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2500+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25202501		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
25212502		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25222503
25232504		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2524- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2505+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25252506		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25262507		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
25272508	} 
@@ -3464,7 +3445,7 @@ mod tests {
34643445		scorer. payment_path_failed ( & path,  43 ,  Duration :: ZERO ) ; 
34653446
34663447		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
3467- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
3448+ 			. as_directed ( & source,  & target,  1_000 ) ; 
34683449		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  256 ) ; 
34693450		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  768 ) ; 
34703451	} 
0 commit comments