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)
|
|
|
|
|
|
|
|
|
2022-11-10 09:07:08 +01:00
|
|
|
def filter(self, conn, block):
|
2022-05-07 13:33:35 +02:00
|
|
|
for fltr in self.filters:
|
2022-11-10 09:07:08 +01:00
|
|
|
fltr.filter(conn, block)
|
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))
|
|
|
|
|
|
|
|
|
2022-11-10 09:07:08 +01:00
|
|
|
def pre_callback(conn):
|
2022-05-10 16:21:49 +02:00
|
|
|
logg.debug('starting sync loop iteration')
|
|
|
|
|
|
|
|
|
2022-11-10 09:07:08 +01:00
|
|
|
def post_callback(conn):
|
2022-05-10 16:21:49 +02:00
|
|
|
logg.debug('ending sync loop iteration')
|
|
|
|
|
|
|
|
|
2022-11-10 09:07:08 +01:00
|
|
|
def block_callback(conn, block):
|
2022-05-10 20:28:35 +02:00
|
|
|
logg.info('processing {} {}'.format(block, datetime.datetime.fromtimestamp(block.timestamp)))
|