|
@@ -45,29 +45,29 @@ def date(t):
|
|
|
return '{}-{:02}-{:02} {:02}:{:02}:{:02}'.format(*time.gmtime(t)[:6])
|
|
|
|
|
|
def dhms(t):
|
|
|
- t,neg = (-t,'-') if t < 0 else (t,' ')
|
|
|
+ t, neg = (-t, '-') if t < 0 else (t, ' ')
|
|
|
return f'{neg}{t//60//60//24} days, {t//60//60%24:02}:{t//60%60:02}:{t%60:02} h/m/s'
|
|
|
|
|
|
def time_diff_warning(t_diff):
|
|
|
if abs(t_diff) > 60*60:
|
|
|
print('Warning: block tip time is {} {} clock time!'.format(
|
|
|
dhms(abs(t_diff)),
|
|
|
- ('behind','ahead of')[t_diff<0]))
|
|
|
+ ('behind', 'ahead of')[t_diff<0]))
|
|
|
|
|
|
async def main():
|
|
|
|
|
|
proto = cfg._proto
|
|
|
|
|
|
from mmgen.rpc import rpc_init
|
|
|
- c = await rpc_init( cfg, proto, ignore_wallet=True )
|
|
|
+ c = await rpc_init(cfg, proto, ignore_wallet=True)
|
|
|
|
|
|
tip = await c.call('getblockcount')
|
|
|
assert tip > 1, 'block tip must be > 1'
|
|
|
remaining = proto.halving_interval - tip % proto.halving_interval
|
|
|
- sample_size = int(cfg.sample_size) if cfg.sample_size else min(tip-1,max(remaining,144))
|
|
|
+ sample_size = int(cfg.sample_size) if cfg.sample_size else min(tip-1, max(remaining, 144))
|
|
|
|
|
|
# aiohttp backend will perform these two calls concurrently:
|
|
|
- cur,old = await c.gathered_call('getblockstats',((tip,),(tip - sample_size,)))
|
|
|
+ cur, old = await c.gathered_call('getblockstats', ((tip,), (tip - sample_size,)))
|
|
|
|
|
|
clock_time = int(time.time())
|
|
|
time_diff_warning(clock_time - cur['time'])
|