WIP implement cic-base in traffic
This commit is contained in:
parent
93b7c9748f
commit
7ac6c9a1e8
@ -3,7 +3,7 @@ import logging
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from cic_registry import CICRegistry
|
from cic_registry.registry import Registry
|
||||||
from eth_token_index import TokenUniqueSymbolIndex
|
from eth_token_index import TokenUniqueSymbolIndex
|
||||||
from eth_accounts_index import AccountRegistry
|
from eth_accounts_index import AccountRegistry
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
|
||||||
from crypto_dev_signer.keystore import DictKeystore
|
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -8,16 +8,24 @@ import json
|
|||||||
# external imports
|
# external imports
|
||||||
import redis
|
import redis
|
||||||
import celery
|
import celery
|
||||||
from chainsyncer.backend import MemBackend
|
from cic_eth_registry.registry import CICRegistry
|
||||||
|
from chainsyncer.backend.memory import MemBackend
|
||||||
from chainsyncer.driver import HeadSyncer
|
from chainsyncer.driver import HeadSyncer
|
||||||
from chainlib.eth.connection import HTTPConnection
|
from chainlib.eth.connection import EthHTTPConnection
|
||||||
from chainlib.eth.gas import DefaultGasOracle
|
from chainlib.eth.gas import RPCGasOracle
|
||||||
from chainlib.eth.nonce import DefaultNonceOracle
|
from chainlib.eth.nonce import RPCNonceOracle
|
||||||
from chainlib.eth.block import block_latest
|
from chainlib.eth.block import block_latest
|
||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
|
from cic_base import (
|
||||||
|
argparse,
|
||||||
|
config,
|
||||||
|
log,
|
||||||
|
rpc,
|
||||||
|
signer as signer_funcs,
|
||||||
|
)
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
import common
|
#import common
|
||||||
from cmd.traffic import (
|
from cmd.traffic import (
|
||||||
TrafficItem,
|
TrafficItem,
|
||||||
TrafficRouter,
|
TrafficRouter,
|
||||||
@ -29,11 +37,11 @@ from cmd.traffic import add_args as add_traffic_args
|
|||||||
|
|
||||||
# common basics
|
# common basics
|
||||||
script_dir = os.path.realpath(os.path.dirname(__file__))
|
script_dir = os.path.realpath(os.path.dirname(__file__))
|
||||||
logg = common.log.create()
|
logg = log.create()
|
||||||
argparser = common.argparse.create(script_dir, common.argparse.full_template)
|
argparser = argparse.create(script_dir, argparse.full_template)
|
||||||
argparser = common.argparse.add(argparser, add_traffic_args, 'traffic')
|
argparser = argparse.add(argparser, add_traffic_args, 'traffic')
|
||||||
args = common.argparse.parse(argparser, logg)
|
args = argparse.parse(argparser, logg)
|
||||||
config = common.config.create(args.c, args, args.env_prefix)
|
config = config.create(args.c, args, args.env_prefix)
|
||||||
|
|
||||||
# map custom args to local config entries
|
# map custom args to local config entries
|
||||||
batchsize = args.batch_size
|
batchsize = args.batch_size
|
||||||
@ -49,30 +57,32 @@ config.add(args.y, '_KEYSTORE_FILE', True)
|
|||||||
|
|
||||||
config.add(args.q, '_CELERY_QUEUE', True)
|
config.add(args.q, '_CELERY_QUEUE', True)
|
||||||
|
|
||||||
common.config.log(config)
|
logg.debug(config)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# create signer (not currently in use, but needs to be accessible for custom traffic item generators)
|
# create signer (not currently in use, but needs to be accessible for custom traffic item generators)
|
||||||
(signer_address, signer) = common.signer.from_keystore(config.get('_KEYSTORE_FILE'))
|
(signer_address, signer) = signer_funcs.from_keystore(config.get('_KEYSTORE_FILE'))
|
||||||
|
|
||||||
# connect to celery
|
# connect to celery
|
||||||
celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL'))
|
celery.Celery(broker=config.get('CELERY_BROKER_URL'), backend=config.get('CELERY_RESULT_URL'))
|
||||||
|
|
||||||
# set up registry
|
# set up registry
|
||||||
w3 = common.rpc.create(config.get('ETH_PROVIDER')) # replace with HTTPConnection when registry has been so refactored
|
rpc.setup(config.get('CIC_CHAIN_SPEC'), config.get('ETH_PROVIDER')) # replace with HTTPConnection when registry has been so refactored
|
||||||
registry = common.registry.init_legacy(config, w3)
|
conn = EthHTTPConnection(config.get('ETH_PROVIDER'))
|
||||||
|
#registry = registry.init_legacy(config, w3)
|
||||||
|
registry = CICRegistry(config.get('CIC_CHAIN_SPEC'), conn)
|
||||||
|
|
||||||
# Connect to blockchain with chainlib
|
# Connect to blockchain with chainlib
|
||||||
conn = HTTPConnection(config.get('ETH_PROVIDER'))
|
gas_oracle = RPCGasOracle(conn)
|
||||||
gas_oracle = DefaultGasOracle(conn)
|
nonce_oracle = RPCNonceOracle(signer_address, conn)
|
||||||
nonce_oracle = DefaultNonceOracle(signer_address, conn)
|
|
||||||
|
|
||||||
# Set up magic traffic handler
|
# Set up magic traffic handler
|
||||||
traffic_router = TrafficRouter()
|
traffic_router = TrafficRouter()
|
||||||
traffic_router.apply_import_dict(config.all(), config)
|
traffic_router.apply_import_dict(config.all(), config)
|
||||||
handler = TrafficSyncHandler(config, traffic_router)
|
handler = TrafficSyncHandler(config, traffic_router)
|
||||||
|
|
||||||
|
return
|
||||||
# Set up syncer
|
# Set up syncer
|
||||||
syncer_backend = MemBackend(config.get('CIC_CHAIN_SPEC'), 0)
|
syncer_backend = MemBackend(config.get('CIC_CHAIN_SPEC'), 0)
|
||||||
o = block_latest()
|
o = block_latest()
|
||||||
|
Loading…
Reference in New Issue
Block a user