eth-monitor

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

commit eedc886179f5e461ccc11551d1071f4f0d7a1d4c
parent a7814de98d6dbfd49f05bd4c6e8b77ee5ac4e9fe
Author: lash <dev@holbrook.no>
Date:   Thu, 13 Oct 2022 07:13:31 +0000

Avoid having to specify session dir when using mem backend

Diffstat:
Meth_monitor/settings.py | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/eth_monitor/settings.py b/eth_monitor/settings.py @@ -53,11 +53,18 @@ def process_monitor_session(settings, config): def process_monitor_session_dir(settings, config): syncer_store_module = None syncer_store_class = None + sync_store = None session_id = settings.get('SESSION_ID') state_dir = None if config.get('SYNCER_BACKEND') == 'mem': syncer_store_module = importlib.import_module('chainsyncer.store.mem') syncer_store_class = getattr(syncer_store_module, 'SyncMemStore') + sync_store = syncer_store_class( + session_id=session_id, + state_event_callback=state_change_callback, + filter_state_event_callback=filter_change_callback, + ) + else: if config.get('SYNCER_BACKEND') == 'fs': syncer_store_module = importlib.import_module('chainsyncer.store.fs') @@ -70,18 +77,18 @@ def process_monitor_session_dir(settings, config): syncer_store_class = getattr(syncer_store_module, 'SyncStore') state_dir = os.path.join(config.get('ETHMONITOR_STATE_DIR'), config.get('SYNCER_BACKEND')) os.makedirs(state_dir, exist_ok=True) - logg.info('using engine {} moduleĀ {}.{}'.format(config.get('SYNCER_BACKEND'), syncer_store_module.__file__, syncer_store_class.__name__)) + session_dir = os.path.join(state_dir, session_id) + sync_store = syncer_store_class( + session_dir, + session_id=session_id, + state_event_callback=state_change_callback, + filter_state_event_callback=filter_change_callback, + ) + settings.set('SESSION_DIR', session_dir) - session_dir = os.path.join(state_dir, session_id) - sync_store = syncer_store_class( - session_dir, - session_id=session_id, - state_event_callback=state_change_callback, - filter_state_event_callback=filter_change_callback, - ) + logg.info('using engine {} moduleĀ {}.{}'.format(config.get('SYNCER_BACKEND'), syncer_store_module.__file__, syncer_store_class.__name__)) settings.set('STATE_DIR', state_dir) - settings.set('SESSION_DIR', session_dir) settings.set('SYNC_STORE', sync_store) return settings