@@ -806,7 +806,6 @@ struct DirectedChannelLiquidity<L: Deref<Target = u64>, BRT: Deref<Target = Hist
806806	capacity_msat :  u64 , 
807807	last_updated :  T , 
808808	offset_history_last_updated :  T , 
809- 	decay_params :  ProbabilisticScoringDecayParameters , 
810809} 
811810
812811impl < G :  Deref < Target  = NetworkGraph < L > > ,  L :  Deref >  ProbabilisticScorer < G ,  L >  where  L :: Target :  Logger  { 
@@ -838,7 +837,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
838837				let  log_direction = |source,  target| { 
839838					if  let  Some ( ( directed_info,  _) )  = chan_debug. as_directed_to ( target)  { 
840839						let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
841- 						let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
840+ 						let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
842841
843842						let  min_buckets = & dir_liq. liquidity_history . min_liquidity_offset_history . buckets ; 
844843						let  max_buckets = & dir_liq. liquidity_history . max_liquidity_offset_history . buckets ; 
@@ -890,7 +889,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
890889			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
891890				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
892891					let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
893- 					let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
892+ 					let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
894893					return  Some ( ( dir_liq. min_liquidity_msat ( ) ,  dir_liq. max_liquidity_msat ( ) ) ) ; 
895894				} 
896895			} 
@@ -932,7 +931,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
932931			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
933932				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
934933					let  amt = directed_info. effective_capacity ( ) . as_msat ( ) ; 
935- 					let  dir_liq = liq. as_directed ( source,  target,  amt,   self . decay_params ) ; 
934+ 					let  dir_liq = liq. as_directed ( source,  target,  amt) ; 
936935
937936					let  min_buckets = dir_liq. liquidity_history . min_liquidity_offset_history . buckets ; 
938937					let  mut  max_buckets = dir_liq. liquidity_history . max_liquidity_offset_history . buckets ; 
@@ -963,7 +962,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ProbabilisticScorer<G, L> whe
963962			if  let  Some ( liq)  = self . channel_liquidities . get ( & scid)  { 
964963				if  let  Some ( ( directed_info,  source) )  = chan. as_directed_to ( target)  { 
965964					let  capacity_msat = directed_info. effective_capacity ( ) . as_msat ( ) ; 
966- 					let  dir_liq = liq. as_directed ( source,  target,  capacity_msat,   self . decay_params ) ; 
965+ 					let  dir_liq = liq. as_directed ( source,  target,  capacity_msat) ; 
967966
968967					return  dir_liq. liquidity_history . calculate_success_probability_times_billion ( 
969968						& params,  amount_msat,  capacity_msat
@@ -990,7 +989,7 @@ impl ChannelLiquidity {
990989	/// Returns a view of the channel liquidity directed from `source` to `target` assuming 
991990/// `capacity_msat`. 
992991fn  as_directed ( 
993- 		& self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 ,   decay_params :   ProbabilisticScoringDecayParameters 
992+ 		& self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 , 
994993	)  -> DirectedChannelLiquidity < & u64 ,  & HistoricalBucketRangeTracker ,  & Duration >  { 
995994		let  ( min_liquidity_offset_msat,  max_liquidity_offset_msat,  min_liquidity_offset_history,  max_liquidity_offset_history)  =
996995			if  source < target { 
@@ -1011,14 +1010,13 @@ impl ChannelLiquidity {
10111010			capacity_msat, 
10121011			last_updated :  & self . last_updated , 
10131012			offset_history_last_updated :  & self . offset_history_last_updated , 
1014- 			decay_params :  decay_params, 
10151013		} 
10161014	} 
10171015
10181016	/// Returns a mutable view of the channel liquidity directed from `source` to `target` assuming 
10191017/// `capacity_msat`. 
10201018fn  as_directed_mut ( 
1021- 		& mut  self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 ,   decay_params :   ProbabilisticScoringDecayParameters 
1019+ 		& mut  self ,  source :  & NodeId ,  target :  & NodeId ,  capacity_msat :  u64 , 
10221020	)  -> DirectedChannelLiquidity < & mut  u64 ,  & mut  HistoricalBucketRangeTracker ,  & mut  Duration >  { 
10231021		let  ( min_liquidity_offset_msat,  max_liquidity_offset_msat,  min_liquidity_offset_history,  max_liquidity_offset_history)  =
10241022			if  source < target { 
@@ -1039,7 +1037,6 @@ impl ChannelLiquidity {
10391037			capacity_msat, 
10401038			last_updated :  & mut  self . last_updated , 
10411039			offset_history_last_updated :  & mut  self . offset_history_last_updated , 
1042- 			decay_params :  decay_params, 
10431040		} 
10441041	} 
10451042
@@ -1289,14 +1286,6 @@ DirectedChannelLiquidity<L, BRT, T> {
12891286/// state"), we allow the caller to set an offset applied to our liquidity bounds which 
12901287/// represents the amount of the successful payment we just made. 
12911288fn  update_history_buckets ( & mut  self ,  bucket_offset_msat :  u64 ,  duration_since_epoch :  Duration )  { 
1292- 		let  half_lives =
1293- 			duration_since_epoch. checked_sub ( * self . offset_history_last_updated ) 
1294- 			. unwrap_or ( Duration :: ZERO ) . as_secs ( ) 
1295- 			. checked_div ( self . decay_params . historical_no_updates_half_life . as_secs ( ) ) 
1296- 			. map ( |v| v. try_into ( ) . unwrap_or ( u32:: max_value ( ) ) ) . unwrap_or ( u32:: max_value ( ) ) ; 
1297- 		self . liquidity_history . min_liquidity_offset_history . time_decay_data ( half_lives) ; 
1298- 		self . liquidity_history . max_liquidity_offset_history . time_decay_data ( half_lives) ; 
1299- 
13001289		self . liquidity_history . min_liquidity_offset_history . track_datapoint ( 
13011290			* self . min_liquidity_offset_msat  + bucket_offset_msat,  self . capacity_msat 
13021291		) ; 
@@ -1369,7 +1358,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreLookUp for Probabilistic
13691358		self . channel_liquidities 
13701359			. get ( & scid) 
13711360			. unwrap_or ( & ChannelLiquidity :: new ( Duration :: ZERO ) ) 
1372- 			. as_directed ( & source,  & target,  capacity_msat,   self . decay_params ) 
1361+ 			. as_directed ( & source,  & target,  capacity_msat) 
13731362			. penalty_msat ( amount_msat,  score_params) 
13741363			. saturating_add ( anti_probing_penalty_msat) 
13751364			. saturating_add ( base_penalty_msat) 
@@ -1399,14 +1388,14 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreUpdate for Probabilistic
13991388					self . channel_liquidities 
14001389						. entry ( hop. short_channel_id ) 
14011390						. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1402- 						. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1391+ 						. as_directed_mut ( source,  & target,  capacity_msat) 
14031392						. failed_at_channel ( amount_msat,  duration_since_epoch, 
14041393							format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
14051394				}  else  { 
14061395					self . channel_liquidities 
14071396						. entry ( hop. short_channel_id ) 
14081397						. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1409- 						. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1398+ 						. as_directed_mut ( source,  & target,  capacity_msat) 
14101399						. failed_downstream ( amount_msat,  duration_since_epoch, 
14111400							format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
14121401				} 
@@ -1435,7 +1424,7 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref> ScoreUpdate for Probabilistic
14351424				self . channel_liquidities 
14361425					. entry ( hop. short_channel_id ) 
14371426					. or_insert_with ( || ChannelLiquidity :: new ( duration_since_epoch) ) 
1438- 					. as_directed_mut ( source,  & target,  capacity_msat,   self . decay_params ) 
1427+ 					. as_directed_mut ( source,  & target,  capacity_msat) 
14391428					. successful ( amount_msat,  duration_since_epoch, 
14401429						format_args ! ( "SCID {}, towards {:?}" ,  hop. short_channel_id,  target) ,  & self . logger ) ; 
14411430			}  else  { 
@@ -1959,14 +1948,6 @@ mod bucketed_history {
19591948				self . buckets [ bucket]  = self . buckets [ bucket] . saturating_add ( BUCKET_FIXED_POINT_ONE ) ; 
19601949			} 
19611950		} 
1962- 		/// Decay all buckets by the given number of half-lives. Used to more aggressively remove old 
1963- /// datapoints as we receive newer information. 
1964- #[ inline]  
1965- 		pub ( super )  fn  time_decay_data ( & mut  self ,  half_lives :  u32 )  { 
1966- 			for  e in  self . buckets . iter_mut ( )  { 
1967- 				* e = e. checked_shr ( half_lives) . unwrap_or ( 0 ) ; 
1968- 			} 
1969- 		} 
19701951	} 
19711952
19721953	impl_writeable_tlv_based ! ( HistoricalBucketRangeTracker ,  {  ( 0 ,  buckets,  required)  } ) ; 
@@ -2359,52 +2340,52 @@ mod tests {
23592340		// Update minimum liquidity. 
23602341
23612342		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2362- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2343+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23632344		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23642345		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23652346
23662347		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2367- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2348+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23682349		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23692350		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23702351
23712352		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2372- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2353+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
23732354			. set_min_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
23742355
23752356		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2376- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2357+ 			. as_directed ( & source,  & target,  1_000 ) ; 
23772358		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
23782359		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23792360
23802361		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2381- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2362+ 			. as_directed ( & target,  & source,  1_000 ) ; 
23822363		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23832364		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
23842365
23852366		// Update maximum liquidity. 
23862367
23872368		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2388- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2369+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
23892370		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
23902371		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  900 ) ; 
23912372
23922373		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2393- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2374+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
23942375		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  100 ) ; 
23952376		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
23962377
23972378		scorer. channel_liquidities . get_mut ( & 43 ) . unwrap ( ) 
2398- 			. as_directed_mut ( & target,  & recipient,  1_000 ,  decay_params ) 
2379+ 			. as_directed_mut ( & target,  & recipient,  1_000 ) 
23992380			. set_max_liquidity_msat ( 200 ,  Duration :: ZERO ) ; 
24002381
24012382		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2402- 			. as_directed ( & target,  & recipient,  1_000 ,  decay_params ) ; 
2383+ 			. as_directed ( & target,  & recipient,  1_000 ) ; 
24032384		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24042385		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  200 ) ; 
24052386
24062387		let  liquidity = scorer. channel_liquidities . get ( & 43 ) . unwrap ( ) 
2407- 			. as_directed ( & recipient,  & target,  1_000 ,  decay_params ) ; 
2388+ 			. as_directed ( & recipient,  & target,  1_000 ) ; 
24082389		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  800 ) ; 
24092390		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1000 ) ; 
24102391	} 
@@ -2430,42 +2411,42 @@ mod tests {
24302411
24312412		// Check initial bounds. 
24322413		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2433- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2414+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24342415		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24352416		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24362417
24372418		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2438- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2419+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24392420		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
24402421		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24412422
24422423		// Reset from source to target. 
24432424		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2444- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2425+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
24452426			. set_min_liquidity_msat ( 900 ,  Duration :: ZERO ) ; 
24462427
24472428		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2448- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2429+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24492430		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  900 ) ; 
24502431		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24512432
24522433		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2453- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2434+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24542435		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24552436		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  100 ) ; 
24562437
24572438		// Reset from target to source. 
24582439		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2459- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2440+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
24602441			. set_min_liquidity_msat ( 400 ,  Duration :: ZERO ) ; 
24612442
24622443		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2463- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2444+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24642445		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
24652446		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
24662447
24672448		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2468- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2449+ 			. as_directed ( & target,  & source,  1_000 ) ; 
24692450		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24702451		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
24712452	} 
@@ -2491,42 +2472,42 @@ mod tests {
24912472
24922473		// Check initial bounds. 
24932474		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2494- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2475+ 			. as_directed ( & source,  & target,  1_000 ) ; 
24952476		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
24962477		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  800 ) ; 
24972478
24982479		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2499- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2480+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25002481		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  200 ) ; 
25012482		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
25022483
25032484		// Reset from source to target. 
25042485		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2505- 			. as_directed_mut ( & source,  & target,  1_000 ,  decay_params ) 
2486+ 			. as_directed_mut ( & source,  & target,  1_000 ) 
25062487			. set_max_liquidity_msat ( 300 ,  Duration :: ZERO ) ; 
25072488
25082489		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2509- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2490+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25102491		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25112492		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  300 ) ; 
25122493
25132494		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2514- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2495+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25152496		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  700 ) ; 
25162497		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25172498
25182499		// Reset from target to source. 
25192500		scorer. channel_liquidities . get_mut ( & 42 ) . unwrap ( ) 
2520- 			. as_directed_mut ( & target,  & source,  1_000 ,  decay_params ) 
2501+ 			. as_directed_mut ( & target,  & source,  1_000 ) 
25212502			. set_max_liquidity_msat ( 600 ,  Duration :: ZERO ) ; 
25222503
25232504		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2524- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
2505+ 			. as_directed ( & source,  & target,  1_000 ) ; 
25252506		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  400 ) ; 
25262507		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  1_000 ) ; 
25272508
25282509		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
2529- 			. as_directed ( & target,  & source,  1_000 ,  decay_params ) ; 
2510+ 			. as_directed ( & target,  & source,  1_000 ) ; 
25302511		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  0 ) ; 
25312512		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  600 ) ; 
25322513	} 
@@ -3660,7 +3641,7 @@ mod tests {
36603641		scorer. payment_path_failed ( & path,  43 ,  Duration :: ZERO ) ; 
36613642
36623643		let  liquidity = scorer. channel_liquidities . get ( & 42 ) . unwrap ( ) 
3663- 			. as_directed ( & source,  & target,  1_000 ,  decay_params ) ; 
3644+ 			. as_directed ( & source,  & target,  1_000 ) ; 
36643645		assert_eq ! ( liquidity. min_liquidity_msat( ) ,  256 ) ; 
36653646		assert_eq ! ( liquidity. max_liquidity_msat( ) ,  768 ) ; 
36663647	} 
0 commit comments