From: Matt Corallo Date: Mon, 9 Oct 2023 01:11:10 +0000 (+0000) Subject: Stop decaying liquidity information during bounds-based scoring X-Git-Tag: v0.0.119~4^2~10 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=6f8838fe7033b8ab6733baface32bdb183abefc7;p=rust-lightning Stop decaying liquidity information during bounds-based scoring Because scoring is an incredibly performance-sensitive operation, doing liquidity information decay (and especially fetching the current time!) during scoring isn't really a great idea. Now that we decay liquidity information in the background, we don't have any reason to decay during scoring, and we ultimately remove it entirely here. --- diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 4391da8e9..d0766b6a7 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -1260,25 +1260,7 @@ impl, BRT: Deref, } fn decayed_offset_msat(&self, offset_msat: u64) -> u64 { - let half_life = self.decay_params.liquidity_offset_half_life.as_secs(); - if half_life != 0 { - // Decay the offset by the appropriate number of half lives. If half of the next half - // life has passed, approximate an additional three-quarter life to help smooth out the - // decay. - let elapsed_time = self.now.duration_since(*self.last_updated).as_secs(); - let half_decays = elapsed_time / (half_life / 2); - let decays = half_decays / 2; - let decayed_offset_msat = offset_msat.checked_shr(decays as u32).unwrap_or(0); - if half_decays % 2 == 0 { - decayed_offset_msat - } else { - // 11_585 / 16_384 ~= core::f64::consts::FRAC_1_SQRT_2 - // 16_384 == 2^14 - (decayed_offset_msat as u128 * 11_585 / 16_384) as u64 - } - } else { - 0 - } + offset_msat } }