From: Jeffrey Czyz Date: Fri, 7 Jan 2022 14:19:45 +0000 (-0600) Subject: f - Fix decay in mutators X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=d31c9659760779ca5bbed995678cca88e59e981c;p=rust-lightning f - Fix decay in mutators --- diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 627b3dd0a..3577460ac 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -681,24 +681,24 @@ impl, T: Time, U: DerefMut> DirectedChanne /// Adjusts the lower bound of the channel liquidity balance in this direction. fn set_min_liquidity_msat(&mut self, amount_msat: u64) { - *self.last_updated = self.now; *self.min_liquidity_offset_msat = amount_msat; *self.max_liquidity_offset_msat = if amount_msat > self.max_liquidity_msat() { 0 } else { self.decayed_offset_msat(*self.max_liquidity_offset_msat) }; + *self.last_updated = self.now; } /// Adjusts the upper bound of the channel liquidity balance in this direction. fn set_max_liquidity_msat(&mut self, amount_msat: u64) { - *self.last_updated = self.now; *self.max_liquidity_offset_msat = self.capacity_msat.checked_sub(amount_msat).unwrap_or(0); *self.min_liquidity_offset_msat = if amount_msat < self.min_liquidity_msat() { 0 } else { self.decayed_offset_msat(*self.min_liquidity_offset_msat) - } + }; + *self.last_updated = self.now; } }