Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: correctly check cache expiry (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg authored Apr 6, 2022
1 parent c436d19 commit 8f9832d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ impl Cache {
let reader = std::io::BufReader::new(std::fs::File::open(path).ok()?);
if let Ok(inner) = serde_json::from_reader::<_, CacheEnvelope<T>>(reader) {
// If this does not return None then we have passed the expiry
if SystemTime::now().checked_sub(Duration::from_secs(inner.expiry)).is_some() {
if SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("system time is before unix epoch")
.checked_sub(Duration::from_secs(inner.expiry))
.is_some()
{
return None
}

Expand Down

0 comments on commit 8f9832d

Please sign in to comment.