Skip to content

Commit 6f8838f

Browse files
committed
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.
1 parent 35b4964 commit 6f8838f

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

lightning/src/routing/scoring.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,25 +1260,7 @@ impl<L: Deref<Target = u64>, BRT: Deref<Target = HistoricalBucketRangeTracker>,
12601260
}
12611261

12621262
fn decayed_offset_msat(&self, offset_msat: u64) -> u64 {
1263-
let half_life = self.decay_params.liquidity_offset_half_life.as_secs();
1264-
if half_life != 0 {
1265-
// Decay the offset by the appropriate number of half lives. If half of the next half
1266-
// life has passed, approximate an additional three-quarter life to help smooth out the
1267-
// decay.
1268-
let elapsed_time = self.now.duration_since(*self.last_updated).as_secs();
1269-
let half_decays = elapsed_time / (half_life / 2);
1270-
let decays = half_decays / 2;
1271-
let decayed_offset_msat = offset_msat.checked_shr(decays as u32).unwrap_or(0);
1272-
if half_decays % 2 == 0 {
1273-
decayed_offset_msat
1274-
} else {
1275-
// 11_585 / 16_384 ~= core::f64::consts::FRAC_1_SQRT_2
1276-
// 16_384 == 2^14
1277-
(decayed_offset_msat as u128 * 11_585 / 16_384) as u64
1278-
}
1279-
} else {
1280-
0
1281-
}
1263+
offset_msat
12821264
}
12831265
}
12841266

0 commit comments

Comments
 (0)