Skip to content

Commit e1f41be

Browse files
committed
f doc why last_update is a fine current-time standin
1 parent 8e9f6ac commit e1f41be

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
@@ -1277,6 +1277,12 @@ DirectedChannelLiquidity< L, HT, T> {
12771277
}
12781278

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

0 commit comments

Comments
 (0)