4
0
mirror of git://holbrook.no/eth-monitor.git synced 2024-11-16 10:16:48 +01:00
eth-monitor/eth_monitor/callback.py

40 lines
896 B
Python
Raw Normal View History

2022-05-10 16:21:49 +02:00
# standard imports
import logging
logg = logging.getLogger(__name__)
2022-05-07 13:33:35 +02:00
class BlockCallbackFilter:
def __init__(self):
self.filters = []
def register(self, fltr):
self.filters.append(fltr)
def filter(self, block, tx=None):
for fltr in self.filters:
fltr.filter(block, tx=tx)
2022-05-10 16:21:49 +02:00
def state_change_callback(k, old_state, new_state):
logg.log(logging.STATETRACE, 'state change: {} {} -> {}'.format(k, old_state, new_state))
def filter_change_callback(k, old_state, new_state):
logg.log(logging.STATETRACE, 'filter change: {} {} -> {}'.format(k, old_state, new_state))
def pre_callback():
logg.debug('starting sync loop iteration')
def post_callback():
logg.debug('ending sync loop iteration')
def block_callback(block, tx):
logg.info('processing {} {}'.format(block, datetime.datetime.fromtimestamp(block.timestamp)))