mirror of
git://holbrook.no/eth-monitor.git
synced 2024-12-04 08:26:47 +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)
|
self.filters.append(fltr)
|
||||||
|
|
||||||
|
|
||||||
def filter(self, block, tx=None):
|
def filter(self, conn, block):
|
||||||
for fltr in self.filters:
|
for fltr in self.filters:
|
||||||
fltr.filter(block, tx=tx)
|
fltr.filter(conn, block)
|
||||||
|
|
||||||
|
|
||||||
def state_change_callback(k, old_state, new_state):
|
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))
|
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')
|
logg.debug('starting sync loop iteration')
|
||||||
|
|
||||||
|
|
||||||
def post_callback():
|
def post_callback(conn):
|
||||||
logg.debug('ending sync loop iteration')
|
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)))
|
logg.info('processing {} {}'.format(block, datetime.datetime.fromtimestamp(block.timestamp)))
|
||||||
|
@ -16,7 +16,7 @@ class RuledFilter(SyncFilter):
|
|||||||
self.rules_filter = rules_filter
|
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 self.rules_filter != None:
|
||||||
if not self.rules_filter.apply_rules(tx):
|
if not self.rules_filter.apply_rules(tx):
|
||||||
logg.debug('rule match failed for tx {}'.format(tx.hash))
|
logg.debug('rule match failed for tx {}'.format(tx.hash))
|
||||||
|
@ -5,5 +5,5 @@ class Filter:
|
|||||||
self.include_block_data = include_block_data
|
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)
|
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
|
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)
|
self.store.put_tx(tx, include_data=self.include_tx_data)
|
||||||
|
|
||||||
|
|
||||||
def filter(self, conn, block, tx, db_session=None):
|
def filter(self, conn, block, tx, **kwargs):
|
||||||
r = super(Filter, self).filter(conn, block, tx, db_session=db_session)
|
r = super(Filter, self).filter(conn, block, tx, **kwargs)
|
||||||
if r == True:
|
if r == True:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
self.ruled_filter(conn, block, tx, db_session=db_session)
|
self.ruled_filter(conn, block, tx, **kwargs)
|
||||||
return False
|
return False
|
||||||
|
@ -16,7 +16,7 @@ logg = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# Interface defining the signature for renderer in OutFilter
|
# Interface defining the signature for renderer in OutFilter
|
||||||
# return string after local transformation
|
# 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
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ class OutFilter(RuledFilter):
|
|||||||
self.result = OutResult()
|
self.result = OutResult()
|
||||||
|
|
||||||
|
|
||||||
def filter(self, conn, block, tx, db_session=None):
|
def filter(self, conn, block, tx, **kwargs):
|
||||||
r = super(OutFilter, self).filter(conn, block, tx, db_session=db_session)
|
r = super(OutFilter, self).filter(conn, block, tx, **kwargs)
|
||||||
if r == True:
|
if r == True:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class Importer:
|
|||||||
block = Block(r)
|
block = Block(r)
|
||||||
|
|
||||||
if self.block_callback != None:
|
if self.block_callback != None:
|
||||||
self.block_callback(block)
|
self.block_callback(None, block)
|
||||||
|
|
||||||
tx_src = block.txs[int(v['transactionIndex'])]
|
tx_src = block.txs[int(v['transactionIndex'])]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
chainlib-eth~=0.4.1
|
chainlib-eth~=0.4.1
|
||||||
chainlib~=0.4.0
|
chainlib~=0.4.0
|
||||||
chainsyncer~=0.6.0
|
chainsyncer~=0.7.0
|
||||||
leveldir~=0.3.0
|
leveldir~=0.3.0
|
||||||
eth-cache~=0.2.0
|
eth-cache~=0.2.0
|
||||||
confini~=0.6.3
|
confini~=0.6.3
|
||||||
|
Loading…
Reference in New Issue
Block a user