From a4370c26b0420fe59b1183e6f3fd1c747d11c6d2 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 14 Dec 2018 21:27:05 -0600 Subject: [PATCH] do not save blocks that are too old --- onionr/onionrutils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index a6f57013..f94116f0 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -371,6 +371,7 @@ class OnionrUtils: pass # Validate metadata dict for invalid keys to sizes that are too large + maxAge = config.get("general.max_block_age", 2678400) if type(metadata) is dict: for i in metadata: try: @@ -394,6 +395,8 @@ class OnionrUtils: if metadata[i] > self.getEpoch(): logger.warn('Block metadata time stamp is set for the future, which is not allowed.') break + if (self.getEpoch() - metadata[i]) > maxAge: + logger.warn('Block is older than allowed: %s' % (maxAge,)) elif i == 'expire': try: assert int(metadata[i]) > self.getEpoch()