diff --git a/eth_monitor/cli/arg.py b/eth_monitor/cli/arg.py index c5316d4..4a00ed9 100644 --- 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 index 0a96308..458aff6 100644 --- 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 index 262e5f3..a184504 100644 --- 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 index f90b18b..a5f42e8 100644 --- 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 index e4a3bfd..1dfa9dd 100644 --- 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