Skip to content

Commit dea238b

Browse files
committed
Correct the directionality of liquidity non-update messages
When we log liquidity updates, if we decline to update anything as the new bounds are already within the old bounds, the directionality of the log entries was reversed. While we're at it, we also log the old values.
1 parent 7544030 commit dea238b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lightning/src/routing/scoring.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -753,21 +753,23 @@ impl<L: Deref<Target = u64>, T: Time, U: Deref<Target = T>> DirectedChannelLiqui
753753
impl<L: DerefMut<Target = u64>, T: Time, U: DerefMut<Target = T>> DirectedChannelLiquidity<L, T, U> {
754754
/// Adjusts the channel liquidity balance bounds when failing to route `amount_msat`.
755755
fn failed_at_channel<Log: Deref>(&mut self, amount_msat: u64, chan_descr: fmt::Arguments, logger: &Log) where Log::Target: Logger {
756-
if amount_msat < self.max_liquidity_msat() {
757-
log_debug!(logger, "Setting max liquidity of {} to {}", chan_descr, amount_msat);
756+
let existing_max_msat = self.max_liquidity_msat();
757+
if amount_msat < existing_max_msat {
758+
log_debug!(logger, "Setting max liquidity of {} from {} to {}", chan_descr, existing_max_msat, amount_msat);
758759
self.set_max_liquidity_msat(amount_msat);
759760
} else {
760-
log_trace!(logger, "Max liquidity of {} already more than {}", chan_descr, amount_msat);
761+
log_trace!(logger, "Max liquidity of {} is {} (already less than {})", chan_descr, existing_max_msat, amount_msat);
761762
}
762763
}
763764

764765
/// Adjusts the channel liquidity balance bounds when failing to route `amount_msat` downstream.
765766
fn failed_downstream<Log: Deref>(&mut self, amount_msat: u64, chan_descr: fmt::Arguments, logger: &Log) where Log::Target: Logger {
766-
if amount_msat > self.min_liquidity_msat() {
767-
log_debug!(logger, "Setting min liquidity of {} to {}", chan_descr, amount_msat);
767+
let existing_min_msat = self.min_liquidity_msat();
768+
if amount_msat > existing_min_msat {
769+
log_debug!(logger, "Setting min liquidity of {} from {} to {}", existing_min_msat, chan_descr, amount_msat);
768770
self.set_min_liquidity_msat(amount_msat);
769771
} else {
770-
log_trace!(logger, "Min liquidity of {} already less than {}", chan_descr, amount_msat);
772+
log_trace!(logger, "Min liquidity of {} is {} (already more than {})", chan_descr, existing_min_msat, amount_msat);
771773
}
772774
}
773775

0 commit comments

Comments
 (0)