Skip to content

Commit c2f5529

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 5ef158d commit c2f5529

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
@@ -1261,25 +1261,7 @@ impl<L: Deref<Target = u64>, BRT: Deref<Target = HistoricalBucketRangeTracker>,
12611261
}
12621262

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

0 commit comments

Comments
 (0)