eth-monitor

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

cache.py (733B)


      1 # standard imports
      2 import logging
      3 
      4 # local imports
      5 from eth_monitor.filters import RuledFilter
      6 
      7 logg = logging.getLogger(__name__)
      8 
      9 
     10 class Filter(RuledFilter):
     11 
     12     def __init__(self, store, rules_filter=None, include_tx_data=False):
     13         super(Filter, self).__init__(rules_filter=rules_filter)
     14         self.store = store
     15         self.include_tx_data = include_tx_data
     16 
     17 
     18     def ruled_filter(self, conn, block, tx, **kwargs):
     19         self.store.put_tx(tx, include_data=self.include_tx_data)
     20 
     21 
     22     def filter(self, conn, block, tx, **kwargs):
     23         r = super(Filter, self).filter(conn, block, tx, **kwargs)
     24 
     25         if r == True:
     26             return True
     27 
     28         self.ruled_filter(conn, block, tx, **kwargs)
     29         return False