]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f - Fix decay in mutators
authorJeffrey Czyz <jkczyz@gmail.com>
Fri, 7 Jan 2022 14:19:45 +0000 (08:19 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Thu, 20 Jan 2022 22:14:47 +0000 (16:14 -0600)
lightning/src/routing/scoring.rs

index 627b3dd0a79a9ad143a53111418e954f113d3442..3577460ac4ea0d9cdf0e91b3336eade62c3bcb30 100644 (file)
@@ -681,24 +681,24 @@ impl<L: DerefMut<Target = u64>, T: Time, U: DerefMut<Target = T>> 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;
        }
 }