do not save blocks that are too old
parent
8e35b8b7ad
commit
a4370c26b0
|
@ -371,6 +371,7 @@ class OnionrUtils:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Validate metadata dict for invalid keys to sizes that are too large
|
# 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:
|
if type(metadata) is dict:
|
||||||
for i in metadata:
|
for i in metadata:
|
||||||
try:
|
try:
|
||||||
|
@ -394,6 +395,8 @@ class OnionrUtils:
|
||||||
if metadata[i] > self.getEpoch():
|
if metadata[i] > self.getEpoch():
|
||||||
logger.warn('Block metadata time stamp is set for the future, which is not allowed.')
|
logger.warn('Block metadata time stamp is set for the future, which is not allowed.')
|
||||||
break
|
break
|
||||||
|
if (self.getEpoch() - metadata[i]) > maxAge:
|
||||||
|
logger.warn('Block is older than allowed: %s' % (maxAge,))
|
||||||
elif i == 'expire':
|
elif i == 'expire':
|
||||||
try:
|
try:
|
||||||
assert int(metadata[i]) > self.getEpoch()
|
assert int(metadata[i]) > self.getEpoch()
|
||||||
|
|
Loading…
Reference in New Issue