From b9b49267c8db9483bc93577afa4884693d6d9cb1 Mon Sep 17 00:00:00 2001 From: astolfo Date: Sun, 23 Jun 2024 17:11:28 -0600 Subject: [PATCH] added fix for Instant::now() subtraction overflow under the case that an individual runs a piece of software depending on this crate, the runtime will panic due to the Instant being smaller than the durection since the UNIX epoch --- src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc.rs b/src/rpc.rs index 91b13f91..48ada1a2 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -97,7 +97,7 @@ impl Rpc { put_queries: HashMap::new(), closest_nodes: LruCache::new(NonZeroUsize::new(MAX_CACHED_BUCKETS).unwrap()), - last_table_refresh: Instant::now() - REFRESH_TABLE_INTERVAL, + last_table_refresh: Instant::now().checked_sub(REFRESH_TABLE_INTERVAL).unwrap_or_else(Instant::now), last_table_ping: Instant::now(), }) }