2021-06-27 11:01:31 +02:00
|
|
|
# standard imports
|
2022-01-23 18:28:25 +01:00
|
|
|
import logging
|
2021-06-27 11:01:31 +02:00
|
|
|
|
2022-01-23 18:49:04 +01:00
|
|
|
# local imports
|
|
|
|
from eth_monitor.filters import RuledFilter
|
2021-06-27 11:01:31 +02:00
|
|
|
|
2022-01-23 18:49:04 +01:00
|
|
|
logg = logging.getLogger(__name__)
|
2021-06-27 11:01:31 +02:00
|
|
|
|
|
|
|
|
2022-01-23 23:07:59 +01:00
|
|
|
class Filter(RuledFilter):
|
2021-06-27 11:01:31 +02:00
|
|
|
|
2022-05-10 20:28:35 +02:00
|
|
|
def __init__(self, store, rules_filter=None, include_tx_data=False):
|
|
|
|
super(Filter, self).__init__(rules_filter=rules_filter)
|
|
|
|
self.store = store
|
|
|
|
self.include_tx_data = include_tx_data
|
|
|
|
|
|
|
|
|
2022-01-23 18:49:04 +01:00
|
|
|
def ruled_filter(self, conn, block, tx, db_session=None):
|
2022-01-23 23:44:31 +01:00
|
|
|
self.store.put_tx(tx, include_data=self.include_tx_data)
|
2022-02-27 14:52:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
def filter(self, conn, block, tx, db_session=None):
|
|
|
|
r = super(Filter, self).filter(conn, block, tx, db_session=db_session)
|
2022-03-30 10:11:46 +02:00
|
|
|
if r == True:
|
2022-02-27 14:52:05 +01:00
|
|
|
return True
|
|
|
|
|
|
|
|
self.ruled_filter(conn, block, tx, db_session=db_session)
|
2022-03-30 10:11:46 +02:00
|
|
|
return False
|