@@ -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  { 
@@ -1953,14 +1942,6 @@ mod bucketed_history {
19531942				self . buckets [ bucket]  = self . buckets [ bucket] . saturating_add ( BUCKET_FIXED_POINT_ONE ) ; 
19541943			} 
19551944		} 
1956- 		/// Decay all buckets by the given number of half-lives. Used to more aggressively remove old 
1957- /// datapoints as we receive newer information. 
1958- #[ inline]  
1959- 		pub ( super )  fn  time_decay_data ( & mut  self ,  half_lives :  u32 )  { 
1960- 			for  e in  self . buckets . iter_mut ( )  { 
1961- 				* e = e. checked_shr ( half_lives) . unwrap_or ( 0 ) ; 
1962- 			} 
1963- 		} 
19641945	} 
19651946
19661947	impl_writeable_tlv_based ! ( HistoricalBucketRangeTracker ,  {  ( 0 ,  buckets,  required)  } ) ; 
@@ -2357,52 +2338,52 @@ mod tests {
23572338		// Update minimum liquidity. 
23582339
23592340		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2360- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2341+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23612342		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23622343		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23632344
23642345		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2365- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2346+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23662347		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23672348		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23682349
23692350		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2370- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2351+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
23712352			. set_min_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
23722353
23732354		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2374- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2355+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23752356		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
23762357		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23772358
23782359		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2379- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2360+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23802361		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23812362		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
23822363
23832364		// Update maximum liquidity. 
23842365
23852366		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2386- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2367+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
23872368		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23882369		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23892370
23902371		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2391- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2372+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
23922373		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23932374		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23942375
23952376		scorer. channel_liquidities . get_mut ( & 43 ) . unwrap ( ) 
2396- 			. as_directed_mut ( & target,  & recipient,  1_000 ,  decay_params ) 
2377+ 			. as_directed_mut ( & target,  & recipient,  1_000 ) 
23972378			. set_max_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
23982379
23992380		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2400- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2381+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
24012382		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24022383		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  200 ) ; 
24032384
24042385		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2405- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2386+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
24062387		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  800 ) ; 
24072388		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1000 ) ; 
24082389	} 
@@ -2428,42 +2409,42 @@ mod tests {
24282409
24292410		// Check initial bounds. 
24302411		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2431- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2412+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24322413		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24332414		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24342415
24352416		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2436- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2417+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24372418		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
24382419		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24392420
24402421		// Reset from source to target. 
24412422		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2442- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2423+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
24432424			. set_min_liquidity_msat ( 900 ,  Duration :: ZERO ) ; 
24442425
24452426		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2446- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2427+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24472428		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  900 ) ; 
24482429		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24492430
24502431		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2451- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2432+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24522433		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24532434		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  100 ) ; 
24542435
24552436		// Reset from target to source. 
24562437		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2457- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2438+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
24582439			. set_min_liquidity_msat ( 400 ,  Duration :: ZERO ) ; 
24592440
24602441		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2461- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2442+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24622443		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24632444		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24642445
24652446		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2466- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2447+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24672448		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24682449		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24692450	} 
@@ -2489,42 +2470,42 @@ mod tests {
24892470
24902471		// Check initial bounds. 
24912472		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2492- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2473+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24932474		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24942475		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24952476
24962477		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2497- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2478+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24982479		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
24992480		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
25002481
25012482		// Reset from source to target. 
25022483		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2503- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2484+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
25042485			. set_max_liquidity_msat ( 300 ,  Duration :: ZERO ) ; 
25052486
25062487		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2507- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2488+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25082489		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25092490		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
25102491
25112492		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2512- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2493+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25132494		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
25142495		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25152496
25162497		// Reset from target to source. 
25172498		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2518- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2499+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
25192500			. set_max_liquidity_msat ( 600 ,  Duration :: ZERO ) ; 
25202501
25212502		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2522- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2503+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25232504		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
25242505		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25252506
25262507		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2527- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2508+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25282509		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25292510		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
25302511	} 
@@ -3467,7 +3448,7 @@ mod tests {
34673448		scorer. payment_path_failed ( & path,  43 ,  Duration :: ZERO ) ; 
34683449
34693450		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
3470- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
3451+ 			. as_directed ( & source,  & target,  1_000 ) ; 
34713452		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  256 ) ; 
34723453		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  768 ) ; 
34733454	} 
0 commit comments