2022-04-24 17:03:21 +02:00
|
|
|
# external imports
|
2022-04-23 11:34:30 +02:00
|
|
|
from stateness.redis import RedisMonitor
|
|
|
|
|
|
|
|
|
2022-04-23 07:29:14 +02:00
|
|
|
class SyncTimeRedisCache:
|
|
|
|
|
|
|
|
def __init__(self, host='localhost', port=6379, db=9999):
|
|
|
|
self.state = RedisMonitor('cic-eth-tracker', host=host, port=port, db=db)
|
|
|
|
self.state.register('lastseen', persist=True)
|
|
|
|
|
|
|
|
def cache_time(self, block, tx):
|
|
|
|
v = self.state.get('lastseen')
|
|
|
|
if v != None:
|
|
|
|
v = int(v.decode('utf-8'))
|
|
|
|
if v > block.timestamp:
|
|
|
|
return
|
|
|
|
self.state.set('lastseen', block.timestamp)
|
|
|
|
|
|
|
|
|