@@ -1129,6 +1129,7 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
11291129 log_trace ! ( logger, "Max liquidity of {} is {} (already less than or equal to {})" ,
11301130 chan_descr, existing_max_msat, amount_msat) ;
11311131 }
1132+ self . update_history_buckets ( ) ;
11321133 }
11331134
11341135 /// Adjusts the channel liquidity balance bounds when failing to route `amount_msat` downstream.
@@ -1141,13 +1142,15 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
11411142 log_trace ! ( logger, "Min liquidity of {} is {} (already greater than or equal to {})" ,
11421143 chan_descr, existing_min_msat, amount_msat) ;
11431144 }
1145+ self . update_history_buckets ( ) ;
11441146 }
11451147
11461148 /// Adjusts the channel liquidity balance bounds when successfully routing `amount_msat`.
11471149 fn successful < Log : Deref > ( & mut self , amount_msat : u64 , chan_descr : fmt:: Arguments , logger : & Log ) where Log :: Target : Logger {
11481150 let max_liquidity_msat = self . max_liquidity_msat ( ) . checked_sub ( amount_msat) . unwrap_or ( 0 ) ;
11491151 log_debug ! ( logger, "Subtracting {} from max liquidity of {} (setting it to {})" , amount_msat, chan_descr, max_liquidity_msat) ;
11501152 self . set_max_liquidity_msat ( max_liquidity_msat) ;
1153+ self . update_history_buckets ( ) ;
11511154 }
11521155
11531156 fn update_history_buckets ( & mut self ) {
@@ -1157,11 +1160,13 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
11571160 self . min_liquidity_offset_history . time_decay_data ( half_lives) ;
11581161 self . max_liquidity_offset_history . time_decay_data ( half_lives) ;
11591162
1163+ let min_liquidity_offset_msat = self . decayed_offset_msat ( * self . min_liquidity_offset_msat ) ;
11601164 self . min_liquidity_offset_history . track_datapoint (
1161- * self . min_liquidity_offset_msat , self . capacity_msat
1165+ min_liquidity_offset_msat, self . capacity_msat
11621166 ) ;
1167+ let max_liquidity_offset_msat = self . decayed_offset_msat ( * self . max_liquidity_offset_msat ) ;
11631168 self . max_liquidity_offset_history . track_datapoint (
1164- * self . max_liquidity_offset_msat , self . capacity_msat
1169+ max_liquidity_offset_msat, self . capacity_msat
11651170 ) ;
11661171 }
11671172
@@ -1173,7 +1178,6 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
11731178 } else {
11741179 self . decayed_offset_msat ( * self . max_liquidity_offset_msat )
11751180 } ;
1176- self . update_history_buckets ( ) ;
11771181 * self . last_updated = self . now ;
11781182 }
11791183
@@ -1185,7 +1189,6 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
11851189 } else {
11861190 self . decayed_offset_msat ( * self . min_liquidity_offset_msat )
11871191 } ;
1188- self . update_history_buckets ( ) ;
11891192 * self . last_updated = self . now ;
11901193 }
11911194}
@@ -2800,7 +2803,7 @@ mod tests {
28002803 effective_capacity : EffectiveCapacity :: Total { capacity_msat : 1_024 , htlc_maximum_msat : 1_024 } ,
28012804 } ;
28022805 scorer. payment_path_failed ( & payment_path_for_amount ( 1 ) . iter ( ) . collect :: < Vec < _ > > ( ) , 42 ) ;
2803- assert_eq ! ( scorer. channel_penalty_msat( 42 , & source, & target, usage) , 2048 ) ;
2806+ assert_eq ! ( scorer. channel_penalty_msat( 42 , & source, & target, usage) , 409 ) ;
28042807 }
28052808
28062809 #[ test]
0 commit comments