From a416667a2b0f4e90be85bf6325e8ba0f9cbe9a42 Mon Sep 17 00:00:00 2001 From: Fedor Sakharov Date: Tue, 27 Oct 2020 18:12:53 +0300 Subject: [PATCH] Should check Duration subtraction (#1860) --- polkadot/node/core/av-store/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/node/core/av-store/src/lib.rs b/polkadot/node/core/av-store/src/lib.rs index ce73e02df1..438fb461fb 100644 --- a/polkadot/node/core/av-store/src/lib.rs +++ b/polkadot/node/core/av-store/src/lib.rs @@ -174,7 +174,7 @@ struct NextPoVPruning(Duration); impl NextPoVPruning { // After which duration from `now` this should fire. fn should_fire_in(&self) -> Result { - Ok(self.0 - SystemTime::now().duration_since(UNIX_EPOCH)?) + Ok(self.0.checked_sub(SystemTime::now().duration_since(UNIX_EPOCH)?).unwrap_or_default()) } } @@ -192,7 +192,7 @@ struct NextChunkPruning(Duration); impl NextChunkPruning { // After which amount of seconds into the future from `now` this should fire. fn should_fire_in(&self) -> Result { - Ok(self.0 - SystemTime::now().duration_since(UNIX_EPOCH)?) + Ok(self.0.checked_sub(SystemTime::now().duration_since(UNIX_EPOCH)?).unwrap_or_default()) } }