eth-monitor

Monitor and cache ethereum transactions with match filters
git clone git://git.defalsify.org/eth-monitor.git
Log | Files | Refs | README | LICENSE

commit a175ea79eef4c1da925a6445331ce3c4a69173be
parent 243bc86b7391bd44ff46cb4e9600a21bb4247492
Author: lash <dev@holbrook.no>
Date:   Thu, 10 Nov 2022 08:07:08 +0000

Update filter and callback signatures to chainsyncer 0.7.x

Diffstat:
Meth_monitor/callback.py | 10+++++-----
Meth_monitor/filters/base.py | 2+-
Meth_monitor/filters/block.py | 2+-
Meth_monitor/filters/cache.py | 8++++----
Meth_monitor/filters/out.py | 6+++---
Meth_monitor/importers/etherscan.py | 2+-
Mrequirements.txt | 2+-
7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/eth_monitor/callback.py b/eth_monitor/callback.py @@ -14,9 +14,9 @@ class BlockCallbackFilter: self.filters.append(fltr) - def filter(self, block, tx=None): + def filter(self, conn, block): for fltr in self.filters: - fltr.filter(block, tx=tx) + fltr.filter(conn, block) def state_change_callback(k, old_state, new_state): @@ -27,13 +27,13 @@ def filter_change_callback(k, old_state, new_state): logg.log(logging.STATETRACE, 'filter change: {} {} -> {}'.format(k, old_state, new_state)) -def pre_callback(): +def pre_callback(conn): logg.debug('starting sync loop iteration') -def post_callback(): +def post_callback(conn): logg.debug('ending sync loop iteration') -def block_callback(block, tx): +def block_callback(conn, block): logg.info('processing {} {}'.format(block, datetime.datetime.fromtimestamp(block.timestamp))) diff --git a/eth_monitor/filters/base.py b/eth_monitor/filters/base.py @@ -16,7 +16,7 @@ class RuledFilter(SyncFilter): self.rules_filter = rules_filter - def filter(self, conn, block, tx, db_session=None): + def filter(self, conn, block, tx, **kwargs): if self.rules_filter != None: if not self.rules_filter.apply_rules(tx): logg.debug('rule match failed for tx {}'.format(tx.hash)) diff --git a/eth_monitor/filters/block.py b/eth_monitor/filters/block.py @@ -5,5 +5,5 @@ class Filter: self.include_block_data = include_block_data - def filter(self, block, tx=None): + def filter(self, conn, block): self.store.put_block(block, include_data=self.include_block_data) diff --git a/eth_monitor/filters/cache.py b/eth_monitor/filters/cache.py @@ -15,14 +15,14 @@ class Filter(RuledFilter): self.include_tx_data = include_tx_data - def ruled_filter(self, conn, block, tx, db_session=None): + def ruled_filter(self, conn, block, tx, **kwargs): self.store.put_tx(tx, include_data=self.include_tx_data) - def filter(self, conn, block, tx, db_session=None): - r = super(Filter, self).filter(conn, block, tx, db_session=db_session) + def filter(self, conn, block, tx, **kwargs): + r = super(Filter, self).filter(conn, block, tx, **kwargs) if r == True: return True - self.ruled_filter(conn, block, tx, db_session=db_session) + self.ruled_filter(conn, block, tx, **kwargs) return False diff --git a/eth_monitor/filters/out.py b/eth_monitor/filters/out.py @@ -16,7 +16,7 @@ logg = logging.getLogger(__name__) # Interface defining the signature for renderer in OutFilter # return string after local transformation -def apply_interface(c, s, chain_str, conn, block, tx, db_session=None): +def apply_interface(c, s, chain_str, conn, block, tx, **kwargs): pass @@ -49,8 +49,8 @@ class OutFilter(RuledFilter): self.result = OutResult() - def filter(self, conn, block, tx, db_session=None): - r = super(OutFilter, self).filter(conn, block, tx, db_session=db_session) + def filter(self, conn, block, tx, **kwargs): + r = super(OutFilter, self).filter(conn, block, tx, **kwargs) if r == True: return True diff --git a/eth_monitor/importers/etherscan.py b/eth_monitor/importers/etherscan.py @@ -35,7 +35,7 @@ class Importer: block = Block(r) if self.block_callback != None: - self.block_callback(block) + self.block_callback(None, block) tx_src = block.txs[int(v['transactionIndex'])] diff --git a/requirements.txt b/requirements.txt @@ -1,6 +1,6 @@ chainlib-eth~=0.4.1 chainlib~=0.4.0 -chainsyncer~=0.6.0 +chainsyncer~=0.7.0 leveldir~=0.3.0 eth-cache~=0.2.0 confini~=0.6.3