@@ -1129,6 +1129,7 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1129
1129
log_trace ! ( logger, "Max liquidity of {} is {} (already less than or equal to {})" ,
1130
1130
chan_descr, existing_max_msat, amount_msat) ;
1131
1131
}
1132
+ self . update_history_buckets ( ) ;
1132
1133
}
1133
1134
1134
1135
/// 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
1141
1142
log_trace ! ( logger, "Min liquidity of {} is {} (already greater than or equal to {})" ,
1142
1143
chan_descr, existing_min_msat, amount_msat) ;
1143
1144
}
1145
+ self . update_history_buckets ( ) ;
1144
1146
}
1145
1147
1146
1148
/// Adjusts the channel liquidity balance bounds when successfully routing `amount_msat`.
1147
1149
fn successful < Log : Deref > ( & mut self , amount_msat : u64 , chan_descr : fmt:: Arguments , logger : & Log ) where Log :: Target : Logger {
1148
1150
let max_liquidity_msat = self . max_liquidity_msat ( ) . checked_sub ( amount_msat) . unwrap_or ( 0 ) ;
1149
1151
log_debug ! ( logger, "Subtracting {} from max liquidity of {} (setting it to {})" , amount_msat, chan_descr, max_liquidity_msat) ;
1150
1152
self . set_max_liquidity_msat ( max_liquidity_msat) ;
1153
+ self . update_history_buckets ( ) ;
1151
1154
}
1152
1155
1153
1156
fn update_history_buckets ( & mut self ) {
@@ -1157,11 +1160,13 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1157
1160
self . min_liquidity_offset_history . time_decay_data ( half_lives) ;
1158
1161
self . max_liquidity_offset_history . time_decay_data ( half_lives) ;
1159
1162
1163
+ let min_liquidity_offset_msat = self . decayed_offset_msat ( * self . min_liquidity_offset_msat ) ;
1160
1164
self . min_liquidity_offset_history . track_datapoint (
1161
- * self . min_liquidity_offset_msat , self . capacity_msat
1165
+ min_liquidity_offset_msat, self . capacity_msat
1162
1166
) ;
1167
+ let max_liquidity_offset_msat = self . decayed_offset_msat ( * self . max_liquidity_offset_msat ) ;
1163
1168
self . max_liquidity_offset_history . track_datapoint (
1164
- * self . max_liquidity_offset_msat , self . capacity_msat
1169
+ max_liquidity_offset_msat, self . capacity_msat
1165
1170
) ;
1166
1171
}
1167
1172
@@ -1173,7 +1178,6 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1173
1178
} else {
1174
1179
self . decayed_offset_msat ( * self . max_liquidity_offset_msat )
1175
1180
} ;
1176
- self . update_history_buckets ( ) ;
1177
1181
* self . last_updated = self . now ;
1178
1182
}
1179
1183
@@ -1185,7 +1189,6 @@ impl<L: DerefMut<Target = u64>, BRT: DerefMut<Target = HistoricalBucketRangeTrac
1185
1189
} else {
1186
1190
self . decayed_offset_msat ( * self . min_liquidity_offset_msat )
1187
1191
} ;
1188
- self . update_history_buckets ( ) ;
1189
1192
* self . last_updated = self . now ;
1190
1193
}
1191
1194
}
@@ -2800,7 +2803,7 @@ mod tests {
2800
2803
effective_capacity : EffectiveCapacity :: Total { capacity_msat : 1_024 , htlc_maximum_msat : 1_024 } ,
2801
2804
} ;
2802
2805
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 ) ;
2804
2807
}
2805
2808
2806
2809
#[ test]
0 commit comments