File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1178,10 +1178,12 @@ impl<T: Time> Readable for ChannelLiquidity<T> {
11781178 ( 4 , duration_since_epoch, required) ,
11791179 } ) ;
11801180 // On rust prior to 1.60 `Instant::duration_since` will panic if time goes backwards.
1181- // Because we write `last_updated` as wallclock time when we were written and create an
1182- // `Instant` which represents that wallclock time, we may hit that panic if wallclock time
1183- // is before when we were written. Thus, we check if we'd end up with a time in the future
1184- // and just use `now` instead to avoid panicking later.
1181+ // We write `last_updated` as wallclock time even though its ultimately an `Instant` (which
1182+ // is a time from a monotonic clock usually represented as an offset against boot time).
1183+ // Thus, we have to construct an `Instant` by subtracting the difference in wallclock time
1184+ // from the one that was written. However, because `Instant` can panic if we construct one
1185+ // in the future, we must handle wallclock time jumping backwards, which we do by simply
1186+ // using `Instant::now()` in that case.
11851187 let wall_clock_now = T :: duration_since_epoch ( ) ;
11861188 let now = T :: now ( ) ;
11871189 let last_updated = if wall_clock_now > duration_since_epoch {
You can’t perform that action at this time.
0 commit comments