mirror of
git://holbrook.no/eth-monitor.git
synced 2024-11-23 12:26:45 +01:00
Define cache spec arg to allow other backends
This commit is contained in:
parent
ca80c0d75f
commit
7c7317da9d
@ -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')
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,8 +281,10 @@ def process_arg_rules(settings, config):
|
||||
|
||||
|
||||
def process_cache_store(settings, config):
|
||||
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')
|
||||
store = None
|
||||
if cache_dir == None:
|
||||
logg.warning('no cache dir specified, will discard everything!!')
|
||||
from eth_cache.store.null import NullStore
|
||||
@ -292,8 +295,8 @@ def process_cache_store(settings, config):
|
||||
if cache_dir == None:
|
||||
import tempfile
|
||||
cache_dir = tempfile.mkdtemp()
|
||||
logg.info('using cache store {}'.format(store))
|
||||
|
||||
logg.info('using cache store {}'.format(store))
|
||||
settings.set('CACHE_STORE', store)
|
||||
|
||||
return settings
|
||||
|
Loading…
Reference in New Issue
Block a user