modified: mmnode-blocks-info

modified:   mmnode-peerblocks
This commit is contained in:
The MMGen Project 2020-05-16 19:17:06 +00:00
commit 3568682aea
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 16 additions and 9 deletions

View file

@ -99,8 +99,8 @@ class BlocksInfo:
heights = range(self.first,self.last+1)
hashes = await c.gathered_call('getblockhash',[(height,) for height in heights])
print(hashes)
stats = await c.gathered_call('getblockheader',[(H,) for H in hashes])
pdie(stats)
header = await c.gathered_call('getblockheader',[(H,) for H in hashes])
pdie(header)
def print_header(self): pass
@ -137,14 +137,14 @@ class BlocksInfoOverview(BlocksInfo):
'fee90': bf('90%', 'Fee', '{:>3}', 'feerate_percentiles','fp', ['bs'],4),
'fee_avg': bf('Avg', 'Fee', '{:>3}', None, 'bs', [], 'avgfeerate'),
'fee_min': bf('Min', 'Fee', '{:>3}', None, 'bs', [], 'minfeerate'),
'totalfee': bf('', 'Total Fee',' {:>10}','totalfee', 'tf', ['bs'],None),
'totalfee': bf('', 'Total Fee','{:>10}', 'totalfee', 'tf', ['bs'],None),
'outputs': bf('Out-', 'puts', '{:>5}', None, 'bs', [], 'outs'),
'inputs': bf('In- ', 'puts', '{:>5}', None, 'bs', [], 'ins'),
'version': bf('', 'Version', '{:8}', None, 'bh', [], 'versionHex'),
'nTx': bf('', 'nTx ', '{:>5}', None, 'bh', [], 'nTx'),
'subsidy': bf('', 'Subsidy', '{:7}', 'subsidy', 'su', ['bs'], None),
}
dfl_fields = ['block','date','interval','subsidy','size','weight','fee50','fee25','fee10','version']
dfl_fields = ['block','date','interval','subsidy','totalfee','size','weight','fee50','fee25','fee10','version']
funcs = {
'df': lambda self,loc: time.strftime('%Y-%m-%d %X',time.gmtime(self.t_cur)),
'if': lambda self,loc: '{:02}:{:02}'.format(loc.t_diff//60,loc.t_diff%60),

View file

@ -57,21 +57,28 @@ def format_peer_info(peerinfo):
yield pd( d['id'], [], 0 )
def gen_line(peer):
for blk,blk_disp in peer.blocks_data:
if blk == min_height:
yield RED + blk_disp + RESET
else:
if peer.blocks_data:
if peer.blocks_data[0][0] == min_height:
yield RED + peer.blocks_data[0][1] + RESET
peer.blocks_data.pop(0)
for blk,blk_disp in peer.blocks_data:
yield COLORS[blk % 10] + blk_disp + RESET
id_width = max(2,max(len(str(i['id'])) for i in peerinfo))
for peer in gen_peers(peerinfo):
for peer in tuple(gen_peers(peerinfo)):
line = '{:>{iw}}: {}'.format(
peer.id,
' '.join(gen_line(peer)),
iw = id_width )
yield line + ' ' * (term_width - 2 - id_width - peer.screen_width)
def test_format():
import json
info = json.loads(open('test_data/peerinfo.json').read())
print('\n'.join(format_peer_info(info)) + '\n')
sys.exit(0)
async def inflight_display(rpc):
count = 1