commit 7d5f2d9b4ee3d05c533eac56092ced0c55063c47
parent c2d8a034838b8eb894f2b67fc9bb72e98eb03e70
Author: lash <dev@holbrook.no>
Date: Tue, 26 Apr 2022 08:32:56 +0000
Add memory state store
Diffstat:
5 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
@@ -1,3 +1,5 @@
+- 0.4.2
+ * Implement non-persistent (in-memory) sync state
- 0.4.1
* Correct too restrictive python version constraint
- 0.4.0
diff --git a/eth_monitor/data/config/syncer.ini b/eth_monitor/data/config/syncer.ini
@@ -1,3 +1,3 @@
[syncer]
loop_interval = 5
-backend = fs
+backend = mem
diff --git a/eth_monitor/runnable/sync.py b/eth_monitor/runnable/sync.py
@@ -95,6 +95,7 @@ if args.list_backends:
for v in [
'fs',
'rocksdb',
+ 'mem',
]:
print(v)
sys.exit(0)
@@ -396,20 +397,28 @@ def main():
syncer_store_module = None
syncer_store_class = None
- if config.get('SYNCER_BACKEND') == 'fs':
- syncer_store_module = importlib.import_module('chainsyncer.store.fs')
- syncer_store_class = getattr(syncer_store_module, 'SyncFsStore')
- elif config.get('SYNCER_BACKEND') == 'rocksdb':
- syncer_store_module = importlib.import_module('chainsyncer.store.rocksdb')
- syncer_store_class = getattr(syncer_store_module, 'SyncRocksDbStore')
+ 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')
else:
- syncer_store_module = importlib.import_module(config.get('SYNCER_BACKEND'))
- syncer_store_class = getattr(syncer_store_module, 'SyncStore')
+ if config.get('SYNCER_BACKEND') == 'fs':
+ syncer_store_module = importlib.import_module('chainsyncer.store.fs')
+ syncer_store_class = getattr(syncer_store_module, 'SyncFsStore')
+ elif config.get('SYNCER_BACKEND') == 'rocksdb':
+ syncer_store_module = importlib.import_module('chainsyncer.store.rocksdb')
+ syncer_store_class = getattr(syncer_store_module, 'SyncRocksDbStore')
+ else:
+ syncer_store_module = importlib.import_module(config.get('SYNCER_BACKEND'))
+ syncer_store_class = getattr(syncer_store_module, 'SyncStore')
+ state_dir = os.path.join(config.get('_STATE_DIR'), config.get('SYNCER_BACKEND'))
logg.info('using engine {} moduleĀ {}.{}'.format(config.get('SYNCER_BACKEND'), syncer_store_module.__file__, syncer_store_class.__name__))
- state_dir = os.path.join(config.get('_STATE_DIR'), config.get('SYNCER_BACKEND'))
- sync_store = syncer_store_class(state_dir, session_id=config.get('_SESSION_ID'), state_event_callback=state_change_callback, filter_state_event_callback=filter_change_callback)
+ if state_dir == None:
+ sync_store = syncer_store_class(session_id=config.get('_SESSION_ID'), state_event_callback=state_change_callback, filter_state_event_callback=filter_change_callback)
+ else:
+ sync_store = syncer_store_class(state_dir, session_id=config.get('_SESSION_ID'), state_event_callback=state_change_callback, filter_state_event_callback=filter_change_callback)
logg.info('session is {}'.format(sync_store.session_id))
for fltr in filters:
diff --git a/requirements.txt b/requirements.txt
@@ -1,6 +1,6 @@
chainlib-eth>=0.1.0b4,<0.2.0
chainlib>=0.1.0b1,<0.2.0
-chainsyncer~=0.3.2
+chainsyncer~=0.3.5
eth-erc20~=0.2.0
leveldir~=0.3.0
eth-cache~=0.1.0
diff --git a/setup.cfg b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = eth-monitor
-version = 0.4.1
+version = 0.4.2
description = Monitor and cache transactions using match filters
author = Louis Holbrook
author_email = dev@holbrook.no