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

commit 7c7317da9dd77fcb4e51874be1a491e16f01a7cc
parent ca80c0d75f0b7f6ef621486c6b9a1fc615c4b000
Author: lash <dev@holbrook.no>
Date:   Thu, 27 Jun 2024 16:10:30 +0100

Define cache spec arg to allow other backends

Diffstat:
Meth_monitor/cli/arg.py | 2++
Meth_monitor/cli/config.py | 1+
Meth_monitor/filters/cache.py | 1+
Meth_monitor/settings.py | 27+++++++++++++++------------
Msetup.cfg | 2+-
5 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/eth_monitor/cli/arg.py b/eth_monitor/cli/arg.py @@ -2,7 +2,9 @@ def process_args(argparser, args, flags): # session flags argparser.add_argument('--state-dir', dest='state_dir', type=str, help='Directory to store sync state') argparser.add_argument('--session-id', dest='session_id', type=str, help='Use state from specified session id') + # TODO: deprecate! argparser.add_argument('--cache-dir', dest='cache_dir', type=str, help='Directory to store tx data') + argparser.add_argument('--cache-spec', dest='cache_spec', type=str, help='URL backend selector to store tx data') # address rules flags argparser.add_argument('--input', action='append', type=str, help='Add input (recipient) addresses to includes list') diff --git a/eth_monitor/cli/config.py b/eth_monitor/cli/config.py @@ -56,6 +56,7 @@ def process_config(config, arg, args, flags): config.add(getattr(args, 'session_id'), '_SESSION_ID', False) config.add(getattr(args, 'cache_dir'), '_CACHE_DIR', False) + config.add(getattr(args, 'cache_spec'), '_CACHE_SPEC', False) config.add(getattr(args, 'run_dir'), '_RUN_DIR', False) config.add(getattr(args, 'fresh'), '_FRESH', False) diff --git a/eth_monitor/filters/cache.py b/eth_monitor/filters/cache.py @@ -21,6 +21,7 @@ class Filter(RuledFilter): def filter(self, conn, block, tx, **kwargs): r = super(Filter, self).filter(conn, block, tx, **kwargs) + if r == True: return True diff --git a/eth_monitor/settings.py b/eth_monitor/settings.py @@ -35,6 +35,7 @@ from eth_monitor.config import override, list_from_prefix from eth_monitor.filters.out import OutFilter from eth_monitor.filters.block import Filter as BlockFilter from eth_monitor.filters.run import Filter as RunFilter +from eth_monitor.cache import from_cache_spec logg = logging.getLogger(__name__) @@ -280,20 +281,22 @@ def process_arg_rules(settings, config): def process_cache_store(settings, config): - cache_dir = config.get('_CACHE_DIR') - store = None - if cache_dir == None: - logg.warning('no cache dir specified, will discard everything!!') - from eth_cache.store.null import NullStore - store = NullStore() - else: - store = FileStore(settings.get('CHAIN_SPEC'), cache_dir) - cache_dir = os.path.realpath(cache_dir) + cache_spec = config.get('_CACHE_SPEC') + store = from_cache_spec(settings.get('CHAIN_SPEC'), cache_spec) + if store == None: + cache_dir = config.get('_CACHE_DIR') if cache_dir == None: - import tempfile - cache_dir = tempfile.mkdtemp() - logg.info('using cache store {}'.format(store)) + logg.warning('no cache dir specified, will discard everything!!') + from eth_cache.store.null import NullStore + store = NullStore() + else: + store = FileStore(settings.get('CHAIN_SPEC'), cache_dir) + cache_dir = os.path.realpath(cache_dir) + if cache_dir == None: + import tempfile + cache_dir = tempfile.mkdtemp() + logg.info('using cache store {}'.format(store)) settings.set('CACHE_STORE', store) return settings diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-monitor -version = 0.8.9 +version = 0.8.10 description = Monitor and cache transactions using match filters author = Louis Holbrook author_email = dev@holbrook.no