Browse Source

modified: mmnode-blocks-info

philemon 7 years ago
parent
commit
d57c80cf04
1 changed files with 13 additions and 13 deletions
  1. 13 13
      mmnode-blocks-info

+ 13 - 13
mmnode-blocks-info

@@ -31,6 +31,7 @@ opts_data = lambda: {
 --, --longhelp        Print help message for long options (common options)
 --, --longhelp        Print help message for long options (common options)
 -H, --hashes          Display only block numbers and hashes
 -H, --hashes          Display only block numbers and hashes
 -m, --miner-info      Display miner info in coinbase transaction
 -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
 -M, --raw-miner-info  Display miner info in uninterpreted form
 -s, --summary         Print the summary only
 -s, --summary         Print the summary only
 -t, --transaction=t   Search for transaction 't' in specified block range
 -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']:
 		if opt.transaction in b['tx']:
 			Msg('Requested transaction is in block {}'.format(i))
 			Msg('Requested transaction is in block {}'.format(i))
 			sys.exit(0)
 			sys.exit(0)
- 		msg('Checking block {}'.format(i))
+		msg('Checking block {}'.format(i))
 	else:
 	else:
 		gmt = time.gmtime(b['mediantime'])
 		gmt = time.gmtime(b['mediantime'])
 		date = '{}-{:02}-{:02} {:02}:{:02}:{:02}'.format(*gmt[:6])
 		date = '{}-{:02}-{:02} {:02}:{:02}:{:02}'.format(*gmt[:6])
 		if prev_time == None:
 		if prev_time == None:
 			b_prev = b if i == 0 else c.getblock(c.getblockhash(i-1))
 			b_prev = b if i == 0 else c.getblock(c.getblockhash(i-1))
 			first_time = prev_time = b_prev['mediantime']
 			first_time = prev_time = b_prev['mediantime']
- 		et = b['mediantime'] - prev_time
+		et = b['mediantime'] - prev_time
 		prev_time = b['mediantime']
 		prev_time = b['mediantime']
 		if opt.summary:
 		if opt.summary:
 			continue
 			continue
@@ -140,11 +141,10 @@ for i in range(first,last+1):
 								s = miner_strings[ms]
 								s = miner_strings[ms]
 								break
 								break
 						else:
 						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:
 			else:
 				Msg(fs.format(*d))
 				Msg(fs.format(*d))
 
 
@@ -158,10 +158,10 @@ else:
 	blocks = last - first + 1
 	blocks = last - first + 1
 	if blocks > 1:
 	if blocks > 1:
 		fs2 = '{:<15} {}\n'
 		fs2 = '{:<15} {}\n'
- 		et = b['mediantime'] - first_time
- 		ac = et / blocks
+		et = b['mediantime'] - first_time
+		ac = et / blocks
 		if not opt.summary: Msg('')
 		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)))