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
import os
# local imports
from .base import *
from .arg import process_flags
from .config import process_config
## standard imports
#import os
#
## 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')

View File

@ -1,15 +1,14 @@
# local imports
from .base import SyncFlag
def apply_flag(flag):
flag.add('range')
flag.add('head')
flag.alias('sync_range_ext', 'range', 'head')
return flag
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_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