do not save blocks that are too old

This commit is contained in:
Kevin Froman 2018-12-14 21:27:05 -06:00
parent 8e35b8b7ad
commit a4370c26b0

View File

@ -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()