Skip to content

Commit 0dc5fae

Browse files
committed
f doc why last_update is a fine current-time standin
1 parent 2c6a7c9 commit 0dc5fae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning/src/routing/scoring.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,12 @@ DirectedChannelLiquidity< L, HT, T> {
14951495
}
14961496

14971497
if score_params.probing_diversity_penalty_msat != 0 {
1498+
// We use `last_duration_since_epoch` as a stand-in for the current time as we don't
1499+
// want to fetch the current time in every score call (slowing things down
1500+
// substantially on some platforms where a syscall is required), don't want to add an
1501+
// unnecessary `std` requirement. Assuming we're probing somewhat regularly, it should
1502+
// reliably be close to the current time, (and using the last the last time we probed
1503+
// is also fine here).
14981504
let time_since_update = last_duration_since_epoch.saturating_sub(*self.last_datapoint);
14991505
let mul = Duration::from_secs(60 * 60 * 24).saturating_sub(time_since_update).as_secs();
15001506
let penalty = score_params.probing_diversity_penalty_msat.saturating_mul(mul * mul);

0 commit comments

Comments
 (0)