commit c5bd4aad3a4a411347ab8237e6d64dbf48b3fa8c
parent c45e6e3310f812f483ac7c64d70593998098f374
Author: lash <dev@holbrook.no>
Date: Fri, 13 May 2022 13:46:30 +0000
Update cli module for chainlib 0.3.0, fix remaining settings processing
Diffstat:
3 files changed, 18 insertions(+), 30 deletions(-)
diff --git a/chainqueue/cli/__init__.py b/chainqueue/cli/__init__.py
@@ -1,11 +0,0 @@
-# standard imports
-import os
-
-# local imports
-from .arg import process_flags
-from .config import process_config
-
-
-__script_dir = os.path.dirname(os.path.realpath(__file__))
-data_dir = os.path.join(os.path.dirname(__script_dir), 'data')
-config_dir = os.path.join(data_dir, 'config')
diff --git a/chainqueue/cli/arg.py b/chainqueue/cli/arg.py
@@ -1,4 +1,8 @@
-def process_flags(argparser, flags):
- argparser.add_argument('--backend', type=str, help='Backend to use for state store')
- argparser.add_argument('--tx-digest-size', dest='tx_digest_size', type=str, help='Size of transaction hash in bytes')
- argparser.add_argument('--state-dir', dest='state_dir', type=str, help='Directory to store queuer state in')
+def apply_flag(flag):
+ flag.add('queue')
+ return flag
+
+
+def apply_arg(arg):
+ arg.add_long('tx-digest-size', 'queue', type=int, help='Size of transaction hash in bytes')
+ return arg
diff --git a/chainqueue/settings.py b/chainqueue/settings.py
@@ -15,19 +15,14 @@ def process_queue_tx(settings, config):
return settings
-def process_queue_backend(settings, config):
- settings.set('QUEUE_BACKEND', config.get('QUEUE_BACKEND'))
- return settings
-
-
def process_queue_store(settings, config):
- status = Status(settings.o['QUEUE_STORE_FACTORY'], allow_invalid=True)
- settings.set('QUEUE_STATE_STORE'], status)
+ status = Status(settings.get('QUEUE_STORE_FACTORY'), allow_invalid=True)
+ settings.set('QUEUE_STATE_STORE', status)
store = Store(
- settings.o['CHAIN_SPEC'],
- settings.o['QUEUE_STATE_STORE'],
- settings.o['QUEUE_INDEX_STORE'],
- settings.o['QUEUE_COUNTER_STORE'],
+ settings.get('CHAIN_SPEC'),
+ settings.get('QUEUE_STATE_STORE'),
+ settings.get('QUEUE_INDEX_STORE'),
+ settings.get('QUEUE_COUNTER_STORE'),
sync=True,
)
settings.set('QUEUE_STORE', store)
@@ -37,15 +32,15 @@ def process_queue_store(settings, config):
def process_queue_paths(settings, config):
index_dir = config.get('QUEUE_INDEX_PATH')
if index_dir == None:
- index_dir = os.path.join(config.get('QUEUE_STATE_PATH'), 'tx')
+ index_dir = os.path.join(config.get('STATE_PATH'), 'tx')
counter_dir = config.get('QUEUE_COUNTER_PATH')
if counter_dir == None:
- counter_dir = os.path.join(config.get('QUEUE_STATE_PATH'))
+ counter_dir = os.path.join(config.get('STATE_PATH'))
- settings.set('QUEUE_STATE_PATH', config.get('QUEUE_STATE_PATH'))
+ settings.set('QUEUE_STATE_PATH', config.get('STATE_PATH'))
settings.set('QUEUE_INDEX_PATH', index_dir)
- settings.set('QUEUE_COUNTER_PATH'], counter_dir)
+ settings.set('QUEUE_COUNTER_PATH', counter_dir)
return settings