chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 576e62507b6eb32e66415d74001865bf9b1a0968
parent 88870dc12d11d4ca271b01cb48cb9fffa4e5f09c
Author: lash <dev@holbrook.no>
Date:   Fri, 13 May 2022 10:33:26 +0000

Make arg and flag preparations stateless

Diffstat:
Mchainsyncer/cli/__init__.py | 20++++++++++----------
Mchainsyncer/cli/arg.py | 29++++++++++++++---------------
2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/chainsyncer/cli/__init__.py b/chainsyncer/cli/__init__.py @@ -1,12 +1,12 @@ -# standard imports -import os +## standard imports +#import os +# +## local imports +#from .base import * +#from .arg import process_flags +#from .config import process_config -# local imports -from .base import * -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') +#__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/chainsyncer/cli/arg.py b/chainsyncer/cli/arg.py @@ -1,15 +1,14 @@ -# local imports -from .base import SyncFlag - - -def process_flags(argparser, flags): - - if flags & SyncFlag.RANGE > 0: - argparser.add_argument('--offset', type=int, help='Block to start sync from. Default is start of history (0).') - argparser.add_argument('--until', type=int, default=-1, help='Block to stop sync on. Default is stop at block height of first run.') - argparser.add_argument('--single', action='store_true', help='Execute a single sync, regardless of previous states') - if flags & SyncFlag.HEAD > 0: - argparser.add_argument('--head', action='store_true', help='Start from latest block as offset') - argparser.add_argument('--keep-alive', action='store_true', help='Do not stop syncing when caught up') - - argparser.add_argument('--backend', type=str, help='Backend to use for state store') +def apply_flag(flag): + flag.add('range') + flag.add('head') + flag.alias('sync_range_ext', 'range', 'head') + return flag + + +def apply_arg(arg): + arg.add_long('offset', 'range', typ=int, help='Block to start sync from. Default is start of history (0).') + arg.add_long('until', 'range', typ=int, default=-1, help='Block to stop sync on. Default is stop at block height of first run.') + arg.add_long('single', 'range', typ=bool, help='Execute a single sync, regardless of previous states') + arg.add_long('head', 'head', typ=bool, help='Start from latest block as offset') + arg.add_long('keep-alive', 'head', typ=bool, help='Do not stop syncing when caught up') + return arg