diff --git a/mmnode-blocks-info b/mmnode-blocks-info index 7100525..fa6a992 100755 --- a/mmnode-blocks-info +++ b/mmnode-blocks-info @@ -31,6 +31,7 @@ opts_data = lambda: { --, --longhelp Print help message for long options (common options) -H, --hashes Display only block numbers and hashes -m, --miner-info Display miner info in coinbase transaction +-n, --nya Display NYA (New York Agreement) support -M, --raw-miner-info Display miner info in uninterpreted form -s, --summary Print the summary only -t, --transaction=t Search for transaction 't' in specified block range @@ -110,14 +111,14 @@ for i in range(first,last+1): if opt.transaction in b['tx']: Msg('Requested transaction is in block {}'.format(i)) sys.exit(0) - msg('Checking block {}'.format(i)) + msg('Checking block {}'.format(i)) else: gmt = time.gmtime(b['mediantime']) date = '{}-{:02}-{:02} {:02}:{:02}:{:02}'.format(*gmt[:6]) if prev_time == None: b_prev = b if i == 0 else c.getblock(c.getblockhash(i-1)) first_time = prev_time = b_prev['mediantime'] - et = b['mediantime'] - prev_time + et = b['mediantime'] - prev_time prev_time = b['mediantime'] if opt.summary: continue @@ -140,11 +141,10 @@ for i in range(first,last+1): s = miner_strings[ms] break else: - if re.search('mined by',scb,flags=re.I): - s = scb.split('Mined by')[1].strip() - else: - s = '??' - Msg(fs.format(*(d+((' ','NYA ')['NYA' in scb]+s,)))) + try: s = scb.split('ined by')[1].strip() + except: s = '??' + nya_str = (' ','NYA ')['NYA' in scb] if opt.nya else '' + Msg(fs.format(*(d+(nya_str+s,)))) else: Msg(fs.format(*d)) @@ -158,10 +158,10 @@ else: blocks = last - first + 1 if blocks > 1: fs2 = '{:<15} {}\n' - et = b['mediantime'] - first_time - ac = et / blocks + et = b['mediantime'] - first_time + ac = et / blocks if not opt.summary: Msg('') - Msg_r(fs2.format('Range:','{}-{} ({} blocks)'.format(first,last,blocks)) + - fs2.format('Avg size:',total/blocks) + - fs2.format('MB/hr:','{:0.5f}'.format(float(total)*36/10000/et)) + - fs2.format('Avg conf time:','{}:{:02}'.format(ac/60,ac%60))) + Msg_r( fs2.format('Range:','{}-{} ({} blocks)'.format(first,last,blocks)) + + fs2.format('Avg size:',total/blocks) + + fs2.format('MB/hr:','{:0.5f}'.format(float(total)*36/10000/et)) + + fs2.format('Avg conf time:','{}:{:02}'.format(ac/60,ac%60)))