Skip to content

Commit 3e129f3

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 3e129f3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lightning/src/routing/scoring.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -753,21 +753,25 @@ 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 or equal to {})",
762+
chan_descr, existing_max_msat, amount_msat);
761763
}
762764
}
763765

764766
/// Adjusts the channel liquidity balance bounds when failing to route `amount_msat` downstream.
765767
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);
768+
let existing_min_msat = self.min_liquidity_msat();
769+
if amount_msat > existing_min_msat {
770+
log_debug!(logger, "Setting min liquidity of {} from {} to {}", existing_min_msat, chan_descr, amount_msat);
768771
self.set_min_liquidity_msat(amount_msat);
769772
} else {
770-
log_trace!(logger, "Min liquidity of {} already less than {}", chan_descr, amount_msat);
773+
log_trace!(logger, "Min liquidity of {} is {} (already greater than or equal to {})",
774+
chan_descr, existing_min_msat, amount_msat);
771775
}
772776
}
773777

0 commit comments

Comments
 (0)