Implement wait tool on settings module
This commit is contained in:
parent
6ad0edd8a8
commit
e03c5b8035
@ -112,7 +112,7 @@ logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
def get_block(settings):
|
||||
hsh = settings.get('HASH')
|
||||
hsh = settings.get('HASH')[0]
|
||||
r = None
|
||||
if hsh == None:
|
||||
r = get_block_number(
|
||||
|
@ -103,7 +103,6 @@ settings = process_settings_local(settings, config)
|
||||
logg.debug('settings loaded:\n{}'.format(settings))
|
||||
|
||||
|
||||
|
||||
def get_transaction(conn, chain_spec, tx_hash, id_generator):
|
||||
o = transaction(tx_hash, id_generator=id_generator)
|
||||
tx_src = conn.do(o)
|
||||
@ -150,10 +149,11 @@ def get_address(conn, address, id_generator, height):
|
||||
def main():
|
||||
r = None
|
||||
if settings.get('HASH') != None:
|
||||
hsh = settings.get('HASH')[0]
|
||||
r = get_transaction(
|
||||
settings.get('CONN'),
|
||||
settings.get('CHAIN_SPEC'),
|
||||
settings.get('HASH'),
|
||||
hsh,
|
||||
settings.get('RPC_ID_GENERATOR'),
|
||||
)
|
||||
if not config.true('_RAW'):
|
||||
|
@ -64,9 +64,15 @@ config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
||||
def process_config_local(config, arg, args, flags):
|
||||
config.add(args.ignore, '_IGNORE', False)
|
||||
config.add(args.ignore_all, '_IGNORE_ALL', False)
|
||||
config.add(args.hashes, '_HASHES', False)
|
||||
config.add(args.hashes, '_HASH', False)
|
||||
return config
|
||||
|
||||
|
||||
def process_settings_local(settings, config):
|
||||
settings.set('HASH', config.get('_HASH'))
|
||||
return settings
|
||||
|
||||
|
||||
arg_flags = ArgFlag()
|
||||
arg = Arg(arg_flags)
|
||||
flags = arg_flags.STD_READ
|
||||
@ -98,29 +104,30 @@ def main():
|
||||
for hsh in config.get('_IGNORE'):
|
||||
hashes_ignore.append(add_0x(hex_uniform(strip_0x(hsh))))
|
||||
|
||||
if len(config.get('_HASHES')) == 1:
|
||||
if len(settings.get('HASH')) == 1:
|
||||
hsh = settings.get('HASH')[0]
|
||||
try:
|
||||
hsh = add_0x(hex_uniform(strip_0x(config.get('_HASHES')[0])))
|
||||
hashes_ready = [hsh]
|
||||
except ValueError:
|
||||
logg.debug('hash argument not a hash, will try it as a file name')
|
||||
f = open(config.get('_HASHES')[0])
|
||||
f = open(hsh)
|
||||
for hsh in f:
|
||||
logg.debug('hshs {}'.format(hsh))
|
||||
hashes_ready.append(add_0x(hex_uniform(strip_0x(hsh.rstrip()))))
|
||||
hashes_ready.append(hsh)
|
||||
f.close()
|
||||
else:
|
||||
for hsh in config.get('_HASHES'):
|
||||
logg.debug('hsh {}'.format(hsh))
|
||||
hashes_ready.append(add_0x(hex_uniform(strip_0x(hsh))))
|
||||
for hsh in settings.get('HASH'):
|
||||
if hsh in hashes_ready:
|
||||
logg.debug('skipping duplicate hash {}'.format(hsh))
|
||||
continue
|
||||
hashes_ready.append(hsh)
|
||||
|
||||
for hsh in hashes_ready:
|
||||
logg.debug('processing transaction hash {}'.format(hsh))
|
||||
logg.info('processing transaction hash {}'.format(hsh))
|
||||
try:
|
||||
r = settings.get('CONN').wait(hsh)
|
||||
except RevertEthException:
|
||||
if config.get('_IGNORE_ALL') or hsh in hashes_ignore:
|
||||
logg.info('ignoring revert in transaction hash {}'.format(hsh))
|
||||
logg.debug('ignoring revert in transaction hash {}'.format(hsh))
|
||||
continue
|
||||
sys.stderr.write('revert in transaction hash {}\n'.format(hsh))
|
||||
sys.exit(1)
|
||||
@ -128,5 +135,3 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
|
@ -111,19 +111,25 @@ def process_settings_data(settings, config):
|
||||
|
||||
|
||||
def process_settings_hash(settings, config):
|
||||
hsh = None
|
||||
hshs = None
|
||||
try:
|
||||
hsh = config.get('_HASH')
|
||||
hshs = config.get('_HASH')
|
||||
except KeyError:
|
||||
return settings
|
||||
|
||||
if isinstance(hshs, str):
|
||||
hshs = [hshs]
|
||||
|
||||
r = []
|
||||
for hsh in hshs:
|
||||
hsh = strip_0x(hsh)
|
||||
l = len(hsh)
|
||||
if l != 64:
|
||||
raise ValueError('invalid hash length {} for {}'.format(l, hsh))
|
||||
|
||||
hsh = add_0x(hsh)
|
||||
settings.set('HASH', hsh)
|
||||
r.append(hsh)
|
||||
|
||||
settings.set('HASH', r)
|
||||
|
||||
return settings
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user