Syncer refactor
This commit is contained in:
@@ -48,7 +48,7 @@ argparser = argparse.ArgumentParser(description='daemon that monitors transactio
|
||||
argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address')
|
||||
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
|
||||
argparser.add_argument('-c', type=str, default=config_dir, help='config root to use')
|
||||
argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='oldchain:1', help='chain spec')
|
||||
argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='evm:oldchain:1', help='chain spec')
|
||||
argparser.add_argument('-i', '--chain-spec', type=str, dest='i', help='chain spec')
|
||||
argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address')
|
||||
argparser.add_argument('--token-symbol', default='SRF', type=str, dest='token_symbol', help='Token symbol to use for trnsactions')
|
||||
@@ -101,6 +101,7 @@ else:
|
||||
|
||||
chain_spec = ChainSpec.from_chain_str(chain_str)
|
||||
old_chain_spec_str = args.old_chain_spec
|
||||
old_chain_spec = ChainSpec.from_chain_str(old_chain_spec_str)
|
||||
|
||||
user_dir = args.user_dir # user_out_dir from import_users.py
|
||||
|
||||
@@ -146,7 +147,7 @@ class Handler:
|
||||
logg.error('no import record of address {}'.format(recipient))
|
||||
return
|
||||
u = Person.deserialize(o)
|
||||
original_address = u.identities['evm'][old_chain_spec_str][0]
|
||||
original_address = u.identities[old_chain_spec.engine()]['{}:{}'.format(old_chain_spec.common_name(), old_chain_spec.network_id())][0]
|
||||
balance = self.balances[original_address]
|
||||
|
||||
# TODO: store token object in handler ,get decimals from there
|
||||
|
||||
@@ -88,7 +88,7 @@ batch_delay = args.batch_delay
|
||||
def register_eth(i, u):
|
||||
redis_channel = str(uuid.uuid4())
|
||||
ps.subscribe(redis_channel)
|
||||
ps.get_message()
|
||||
#ps.get_message()
|
||||
api = Api(
|
||||
config.get('CIC_CHAIN_SPEC'),
|
||||
queue=args.q,
|
||||
@@ -98,18 +98,24 @@ def register_eth(i, u):
|
||||
)
|
||||
t = api.create_account(register=True)
|
||||
|
||||
ps.get_message()
|
||||
m = ps.get_message(timeout=args.timeout)
|
||||
try:
|
||||
r = json.loads(m['data'])
|
||||
address = r['result']
|
||||
except TypeError as e:
|
||||
if m == None:
|
||||
logg.critical('empty response from redis callback (did the service crash?)')
|
||||
else:
|
||||
logg.critical('unexpected response from redis callback: {}'.format(m))
|
||||
sys.exit(1)
|
||||
logg.debug('[{}] register eth {} {}'.format(i, u, address))
|
||||
while True:
|
||||
ps.get_message()
|
||||
m = ps.get_message(timeout=args.timeout)
|
||||
address = None
|
||||
if m['type'] == 'subscribe':
|
||||
logg.debug('skipping subscribe message')
|
||||
continue
|
||||
try:
|
||||
r = json.loads(m['data'])
|
||||
address = r['result']
|
||||
break
|
||||
except TypeError as e:
|
||||
if m == None:
|
||||
logg.critical('empty response from redis callback (did the service crash?)')
|
||||
else:
|
||||
logg.critical('unexpected response from redis callback: {}'.format(m))
|
||||
sys.exit(1)
|
||||
logg.debug('[{}] register eth {} {}'.format(i, u, address))
|
||||
|
||||
return address
|
||||
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
psycopg2==2.8.6
|
||||
chainlib~=0.0.1a15
|
||||
chainsyncer~=0.0.1a10
|
||||
cic-eth==0.10.0a30+build.fdb16130
|
||||
cic-registry~=0.5.3a21
|
||||
confini~=0.3.6rc3
|
||||
celery==4.4.7
|
||||
redis==3.5.3
|
||||
hexathon~=0.0.1a3
|
||||
faker==4.17.1
|
||||
cic-types==0.1.0a7+build.1c254367
|
||||
eth-accounts-index~=0.0.10a10
|
||||
cic-base[full_graph]==0.1.1a10
|
||||
cic-eth==0.10.0a36
|
||||
cic-types==0.1.0a8
|
||||
|
||||
@@ -139,6 +139,7 @@ class Verifier:
|
||||
o = self.erc20_tx_factory.erc20_balance(self.token_address, address)
|
||||
r = self.conn.do(o)
|
||||
actual_balance = int(strip_0x(r), 16)
|
||||
balance = int(balance / 1000000) * 1000000
|
||||
logg.debug('balance for {}: {}'.format(address, balance))
|
||||
if balance != actual_balance:
|
||||
raise VerifierError((actual_balance, balance), 'balance')
|
||||
|
||||
Reference in New Issue
Block a user