chaind-eth

Queue server for ethereum
Log | Files | Refs | README | LICENSE

commit 3d39fea7f876c0e3d3aa8430ed53de1ebea5b28e
parent b19b948be32760d2467cee217d7eda2b4f89f569
Author: lash <dev@holbrook.no>
Date:   Tue, 26 Apr 2022 19:40:58 +0000

WIP implement tasker daemon on new settings setup

Diffstat:
Mchaind/eth/data/config/config.ini | 10----------
Mchaind/eth/runnable/syncer.py | 27++++++++++++++++++++-------
Mchaind/eth/runnable/tasker.py | 43+++++++++++++++++++++----------------------
3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/chaind/eth/data/config/config.ini b/chaind/eth/data/config/config.ini @@ -4,13 +4,3 @@ runtime_dir = id = data_dir = dispatch_delay = 0.01 - -[database] -engine = -name = chaind -driver = -user = -password = -host = -port = -debug = 0 diff --git a/chaind/eth/runnable/syncer.py b/chaind/eth/runnable/syncer.py @@ -3,6 +3,8 @@ import os import logging # external imports +import chainlib.cli +import chainsyncer.cli import chaind.cli from chaind.setup import Environment from chaind.filter import StateFilter @@ -24,21 +26,32 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config') env = Environment(domain='eth', env=os.environ) -arg_flags = chaind.cli.argflag_local_sync -argparser = chaind.cli.ArgumentParser(arg_flags) -local_arg_flags = chaind.cli.argflag_local_sync -argparser.process_local_flags(local_arg_flags) +arg_flags = chainlib.cli.argflag_std_base | chainlib.cli.Flag.CHAIN_SPEC +argparser = chainlib.cli.ArgumentParser(arg_flags) + +local_arg_flags = chaind.cli.argflag_local_base +chaind.cli.process_flags(argparser, local_arg_flags) + +sync_flags = chainsyncer.cli.SyncFlag.RANGE | chainsyncer.cli.SyncFlag.HEAD +chainsyncer.cli.process_flags(argparser, sync_flags) + args = argparser.parse_args() -config = chaind.cli.Config.from_args('eth', args, arg_flags, local_arg_flags) +base_config_dir = [ + chainsyncer.cli.config_dir, + chaind.cli.config_dir, + ] +config = chainlib.cli.Config.from_args(args, arg_flags, base_config_dir=base_config_dir) +config = chainsyncer.cli.process_config(config, args, sync_flags) +config = chaind.cli.process_config(config, args, local_arg_flags) +config.add('eth', 'CHAIND_ENGINE', False) logg.debug('config loaded:\n{}'.format(config)) -settings = ChaindEthSettings() +settings = ChaindEthSettings(include_sync=True) settings.process(config) logg.debug('settings:\n{}'.format(settings)) - def main(): queue_adapter = ChaindFsAdapter( settings.get('CHAIN_SPEC'), diff --git a/chaind/eth/runnable/tasker.py b/chaind/eth/runnable/tasker.py @@ -5,6 +5,7 @@ import signal # external imports import chainlib.eth.cli +import chaind.cli from chaind.session import SessionController from chaind.setup import Environment from chaind.error import ( @@ -30,6 +31,7 @@ from chaind.adapters.fs import ChaindFsAdapter # local imports from chaind.eth.dispatch import EthDispatcher from chaind.eth.cache import EthCacheTx +from chaind.eth.settings import ChaindEthSettings logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() @@ -41,32 +43,29 @@ env = Environment(domain='eth', env=os.environ) arg_flags = chainlib.eth.cli.argflag_std_read argparser = chainlib.eth.cli.ArgumentParser(arg_flags) -argparser.add_argument('--data-dir', type=str, help='data directory') -argparser.add_argument('--runtime-dir', type=str, help='runtime directory') -argparser.add_argument('--session-id', dest='session_id', type=str, help='session identifier') -argparser.add_argument('--dispatch-delay', dest='dispatch_delay', type=float, help='socket timeout before processing queue') + +local_arg_flags = chaind.cli.argflag_local_base | chaind.cli.ChaindFlag.DISPATCH | chaind.cli.ChaindFlag.SOCKET +chaind.cli.process_flags(argparser, local_arg_flags) + args = argparser.parse_args() -extra_args = { - 'runtime_dir': 'SESSION_RUNTIME_DIR', - 'data_dir': 'SESSION_DATA_DIR', - 'session_id': 'SESSION_ID', - 'dispatch_delay': 'SESSION_DISPATCH_DELAY', - } -config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, base_config_dir=config_dir) - -logg.debug('session id {} {}'.format(type(config.get('SESSION_ID')), config.get('SESSION_ID'))) -if config.get('SESSION_ID') == None: - config.add(env.session, 'SESSION_ID', exists_ok=True) -if config.get('SESSION_RUNTIME_DIR') == None: - config.add(env.runtime_dir, 'SESSION_RUNTIME_DIR', exists_ok=True) -if config.get('SESSION_DATA_DIR') == None: - config.add(env.data_dir, 'SESSION_DATA_DIR', exists_ok=True) -if not config.get('SESSION_SOCKET_PATH'): - socket_path = os.path.join(config.get('SESSION_RUNTIME_DIR'), config.get('SESSION_ID'), 'chaind.sock') - config.add(socket_path, 'SESSION_SOCKET_PATH', True) + +base_config_dir = [chaind.cli.config_dir] +config = chainlib.cli.Config.from_args(args, arg_flags, base_config_dir=base_config_dir) +config = chaind.cli.process_config(config, args, local_arg_flags) +config.add('eth', 'CHAIND_ENGINE', False) logg.debug('config loaded:\n{}'.format(config)) +settings = ChaindEthSettings() +settings.process(config) + +logg.debug('settings:\n{}'.format(settings)) + +import sys +sys.exit(0) + + + def process_outgoing(chain_spec, adapter, rpc, limit=100): upcoming = adapter.upcoming() logg.info('process {} {} {}'.format(chain_spec, adapter, rpc))