Update cli module for chainlib 0.3.0, fix remaining settings processing

This commit is contained in:
lash 2022-05-13 13:46:30 +00:00
parent c45e6e3310
commit c5bd4aad3a
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 18 additions and 30 deletions

View File

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

View File

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

View File

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