Skip to content

Commit 40f6175

Browse files
committed
f doc why last_update is a fine current-time standin
1 parent a9d7108 commit 40f6175

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
@@ -1528,6 +1528,12 @@ DirectedChannelLiquidity< L, HT, T> {
15281528
}
15291529

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

0 commit comments

Comments
 (0)