From: Matt Corallo Date: Wed, 5 Oct 2022 02:11:00 +0000 (+0000) Subject: Correct the directionality of liquidity non-update messages X-Git-Tag: v0.0.112~22^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=5d0deacc3debd8ab22216266030265816bf4e29e;p=rust-lightning 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. --- diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index f27464e4d..3030c9308 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -753,21 +753,25 @@ impl, T: Time, U: Deref> DirectedChannelLiqui impl, T: Time, U: DerefMut> DirectedChannelLiquidity { /// Adjusts the channel liquidity balance bounds when failing to route `amount_msat`. fn failed_at_channel(&mut self, amount_msat: u64, chan_descr: fmt::Arguments, logger: &Log) where Log::Target: Logger { - if amount_msat < self.max_liquidity_msat() { - log_debug!(logger, "Setting max liquidity of {} to {}", chan_descr, amount_msat); + let existing_max_msat = self.max_liquidity_msat(); + if amount_msat < existing_max_msat { + log_debug!(logger, "Setting max liquidity of {} from {} to {}", chan_descr, existing_max_msat, amount_msat); self.set_max_liquidity_msat(amount_msat); } else { - log_trace!(logger, "Max liquidity of {} already more than {}", chan_descr, amount_msat); + log_trace!(logger, "Max liquidity of {} is {} (already less than or equal to {})", + chan_descr, existing_max_msat, amount_msat); } } /// Adjusts the channel liquidity balance bounds when failing to route `amount_msat` downstream. fn failed_downstream(&mut self, amount_msat: u64, chan_descr: fmt::Arguments, logger: &Log) where Log::Target: Logger { - if amount_msat > self.min_liquidity_msat() { - log_debug!(logger, "Setting min liquidity of {} to {}", chan_descr, amount_msat); + let existing_min_msat = self.min_liquidity_msat(); + if amount_msat > existing_min_msat { + log_debug!(logger, "Setting min liquidity of {} from {} to {}", existing_min_msat, chan_descr, amount_msat); self.set_min_liquidity_msat(amount_msat); } else { - log_trace!(logger, "Min liquidity of {} already less than {}", chan_descr, amount_msat); + log_trace!(logger, "Min liquidity of {} is {} (already greater than or equal to {})", + chan_descr, existing_min_msat, amount_msat); } }