From db87c8e62e08ddf4954aa53bc4e3661aedd4dfbe Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 22 Mar 2021 14:32:58 +0000 Subject: [PATCH] mmnode-blocks-info: add totals stats --- mmgen/node_tools/BlocksInfo.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mmgen/node_tools/BlocksInfo.py b/mmgen/node_tools/BlocksInfo.py index f0e32dd..dc2967c 100644 --- a/mmgen/node_tools/BlocksInfo.py +++ b/mmgen/node_tools/BlocksInfo.py @@ -95,7 +95,7 @@ class BlocksInfo: ) fs_lsqueeze2 = ('interval',) - all_stats = ['avg','range','diff'] + all_stats = ['avg','totals','range','diff'] dfl_stats = ['range','diff'] noindent_stats = ['avg'] @@ -522,6 +522,26 @@ class BlocksInfo: fs = ''.join(self.gen_fs(self.fnames,fill=skip,add_name=True)).strip() return ('averages', ('Averages:', (fs, dict(gen())) )) + async def create_totals_stats(self): + coin = self.rpc.proto.coin + fields = { + 'interval': ('Solve Time: {} h/m/s', secs_to_dhms), + 'subsidy': ('Subsidy: {} %s' % coin, self.fmt_funcs['su']), + 'totalfee': ('Fees: {} %s' % coin, self.fmt_funcs['tf']), + 'earnings': ('Subsidy+Fees: {} %s' % coin, self.fmt_funcs['tf']), + 'nTx': ('nTx: {}', int), + 'inputs': ('Inputs: {}', int), + 'outputs': ('Outputs: {}', int), + 'utxo_inc': ('UTXO change: {:<+}', int), + } + fnames = list( set(fields) & set(self.fnames) ) + vals = dict( ( name, sum(getattr(blk,name) for blk in self.res) ) for name in fnames ) + if 'subsidy' in vals and 'totalfee' in vals: + vals['earnings'] = vals['subsidy'] + vals['totalfee'] + fnames.append('earnings') + res = [( v[0], k, v[1], vals[k] ) for k,v in fields.items() if k in fnames] + return ( 'totals', ['Totals:'] + res ) + def process_stats_pre(self,i): if self.fnames or i != 0: Msg('')