Provide web3 constructor to tracker rpc client

This commit is contained in:
nolash 2021-03-08 15:51:45 +01:00
parent b37c7f3cc2
commit 2fe205b1e8
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 22 additions and 1 deletions

View File

@ -68,6 +68,21 @@ cic_base.config.log(config)
dsn = dsn_from_config(config)
SessionBase.connect(dsn, pool_size=1, debug=config.true('DATABASE_DEBUG'))
re_websocket = re.compile('^wss?://')
re_http = re.compile('^https?://')
blockchain_provider = config.get('ETH_PROVIDER')
if re.match(re_websocket, blockchain_provider) != None:
blockchain_provider = web3.Web3.WebsocketProvider(blockchain_provider)
elif re.match(re_http, blockchain_provider) != None:
blockchain_provider = web3.Web3.HTTPProvider(blockchain_provider)
else:
raise ValueError('unknown provider url {}'.format(blockchain_provider))
def web3_constructor():
w3 = web3.Web3(blockchain_provider)
return (blockchain_provider, w3)
RpcClient.set_constructor(web3_constructor)
def main():
# parse chain spec object

View File

@ -68,6 +68,7 @@ if args.v == True:
logging.getLogger().setLevel(logging.INFO)
elif args.vv == True:
logging.getLogger().setLevel(logging.DEBUG)
verbose = args.vv or args.v
config_dir = os.path.join(args.c)
os.makedirs(config_dir, 0o777, True)
@ -313,7 +314,8 @@ def main():
r = l.split(',')
try:
address = to_checksum(r[0])
#sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
if not verbose:
sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
logg.debug('loading balance {} {}'.format(i, address).ljust(200))
except ValueError:
break
@ -328,6 +330,7 @@ def main():
verifier = Verifier(conn, api, gas_oracle, chain_spec, account_index_address, sarafu_token_address, user_dir, exit_on_error)
user_new_dir = os.path.join(user_dir, 'new')
i = 0
for x in os.walk(user_new_dir):
for y in x[2]:
if y[len(y)-5:] != '.json':
@ -343,6 +346,8 @@ def main():
f.close()
u = Person.deserialize(o)
if not verbose:
sys.stdout.write('processing {} {}'.format(i, u.identities['evm']).ljust(200) + "\r")
logg.debug('data {}'.format(u.identities['evm']))
subchain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
@ -357,6 +362,7 @@ def main():
logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance))
verifier.verify(new_address, balance)
i += 1
print(verifier)