mirror of
git://holbrook.no/eth-monitor.git
synced 2024-12-03 16:16:45 +01:00
Update filter and callback signatures to chainsyncer 0.7.x
This commit is contained in:
parent
243bc86b73
commit
a175ea79ee
@ -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)))
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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'])]
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user