Make arg and flag preparations stateless

This commit is contained in:
lash 2022-05-13 10:33:26 +00:00
parent 88870dc12d
commit 576e62507b
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 22 additions and 23 deletions

View File

@ -1,12 +1,12 @@
# standard imports ## standard imports
import os #import os
#
# local imports ## local imports
from .base import * #from .base import *
from .arg import process_flags #from .arg import process_flags
from .config import process_config #from .config import process_config
__script_dir = os.path.dirname(os.path.realpath(__file__)) #__script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(os.path.dirname(__script_dir), 'data') #data_dir = os.path.join(os.path.dirname(__script_dir), 'data')
config_dir = os.path.join(data_dir, 'config') #config_dir = os.path.join(data_dir, 'config')

View File

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