diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 8e5ec2b86a1..95bb2559023 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -1178,10 +1178,12 @@ impl Readable for ChannelLiquidity { (4, duration_since_epoch, required), }); // On rust prior to 1.60 `Instant::duration_since` will panic if time goes backwards. - // Because we write `last_updated` as wallclock time when we were written and create an - // `Instant` which represents that wallclock time, we may hit that panic if wallclock time - // is before when we were written. Thus, we check if we'd end up with a time in the future - // and just use `now` instead to avoid panicking later. + // We write `last_updated` as wallclock time even though its ultimately an `Instant` (which + // is a time from a monotonic clock usually represented as an offset against boot time). + // Thus, we have to construct an `Instant` by subtracting the difference in wallclock time + // from the one that was written. However, because `Instant` can panic if we construct one + // in the future, we must handle wallclock time jumping backwards, which we do by simply + // using `Instant::now()` in that case. let wall_clock_now = T::duration_since_epoch(); let now = T::now(); let last_updated = if wall_clock_now > duration_since_epoch {