4
0
mirror of git://holbrook.no/eth-monitor.git synced 2024-11-16 18:26:46 +01:00

Avoid having to specify session dir when using mem backend

This commit is contained in:
lash 2022-10-13 07:13:31 +00:00
parent a7814de98d
commit eedc886179
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -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,8 +77,6 @@ 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,
@ -79,9 +84,11 @@ def process_monitor_session_dir(settings, config):
state_event_callback=state_change_callback,
filter_state_event_callback=filter_change_callback,
)
settings.set('SESSION_DIR', session_dir)
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