4
0
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:
lash 2024-06-27 16:10:30 +01:00
parent ca80c0d75f
commit 7c7317da9d
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 20 additions and 13 deletions

View File

@ -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')

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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