2022-04-23 09:09:48 +02:00
|
|
|
|
# external imports
|
|
|
|
|
from chainlib.eth.constant import ZERO_ADDRESS
|
2022-04-23 11:58:17 +02:00
|
|
|
|
from chainsyncer.filter import SyncFilter as BaseSyncFilter
|
2022-04-23 09:09:48 +02:00
|
|
|
|
|
|
|
|
|
|
2022-04-23 11:58:17 +02:00
|
|
|
|
class SyncFilter(BaseSyncFilter):
|
2022-04-21 00:41:19 +02:00
|
|
|
|
|
2022-04-23 09:09:48 +02:00
|
|
|
|
def __init__(self, chain_spec, registry, queue, caller_address=ZERO_ADDRESS):
|
2022-04-23 11:58:17 +02:00
|
|
|
|
super(SyncFilter, self).__init__()
|
2022-04-21 00:41:19 +02:00
|
|
|
|
self.exec_count = 0
|
|
|
|
|
self.match_count = 0
|
2022-04-23 09:09:48 +02:00
|
|
|
|
self.queue = queue
|
|
|
|
|
self.chain_spec = chain_spec
|
|
|
|
|
self.registry = registry
|
|
|
|
|
self.caller_address = caller_address
|
2022-04-21 00:41:19 +02:00
|
|
|
|
|
|
|
|
|
|
2022-04-23 11:58:17 +02:00
|
|
|
|
def filter(self, conn, block, tx):
|
2022-04-21 00:41:19 +02:00
|
|
|
|
self.exec_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register_match(self):
|
|
|
|
|
self.match_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def to_logline(self, block, tx, v):
|
|
|
|
|
return '{} exec {} match {} block {} tx {}: {}'.format(self, self.exec_count, self.match_count, block.number, tx.index, v)
|