From 3568682aea64f976847ac1a055571ef1a7eb4e8a Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 16 May 2020 19:17:06 +0000 Subject: [PATCH] modified: mmnode-blocks-info modified: mmnode-peerblocks --- mmnode-blocks-info | 8 ++++---- mmnode-peerblocks | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/mmnode-blocks-info b/mmnode-blocks-info index 3b019e6..b7833a5 100755 --- a/mmnode-blocks-info +++ b/mmnode-blocks-info @@ -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), diff --git a/mmnode-peerblocks b/mmnode-peerblocks index b699cba..0c43000 100755 --- a/mmnode-peerblocks +++ b/mmnode-peerblocks @@ -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