mmnode-blocks-info: restore --stats-only option
This commit is contained in:
parent
db87c8e62e
commit
9988943318
2 changed files with 11 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ class BlocksInfo:
|
|||
total_bytes = 0
|
||||
total_weight = 0
|
||||
total_solve_time = 0
|
||||
header_printed = False
|
||||
|
||||
bf = namedtuple('block_info_fields',['fmt_func','src','fs','hdr1','hdr2','key1','key2'])
|
||||
# bh=getblockheader, bs=getblockstats, lo=local
|
||||
|
|
@ -343,7 +344,7 @@ class BlocksInfo:
|
|||
self.t_cur = self.prev_hdrs[n]['time']
|
||||
ret = await self.process_block(self.hdrs[n])
|
||||
self.res.append(ret)
|
||||
if self.fnames:
|
||||
if self.fnames and not self.opt.stats_only:
|
||||
self.output_block(ret,n)
|
||||
|
||||
def output_block(self,data,n):
|
||||
|
|
@ -403,6 +404,7 @@ class BlocksInfo:
|
|||
|
||||
def print_header(self):
|
||||
Msg('\n'.join(self.gen_header()))
|
||||
self.header_printed = True
|
||||
|
||||
def gen_header(self):
|
||||
hdr1 = [v.hdr1 for v in self.fvals]
|
||||
|
|
@ -519,6 +521,8 @@ class BlocksInfo:
|
|||
ret = sum(getattr(block,field) for block in self.res) // len(self.res)
|
||||
func = self.fields[field].fmt_func
|
||||
yield ( field, ( (self.fmt_funcs[func] if func else '{}'), ret ))
|
||||
if not self.header_printed:
|
||||
self.print_header()
|
||||
fs = ''.join(self.gen_fs(self.fnames,fill=skip,add_name=True)).strip()
|
||||
return ('averages', ('Averages:', (fs, dict(gen())) ))
|
||||
|
||||
|
|
@ -543,7 +547,7 @@ class BlocksInfo:
|
|||
return ( 'totals', ['Totals:'] + res )
|
||||
|
||||
def process_stats_pre(self,i):
|
||||
if self.fnames or i != 0:
|
||||
if (self.fnames and not self.opt.stats_only) or i != 0:
|
||||
Msg('')
|
||||
|
||||
def finalize_output(self): pass
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ opts_data = {
|
|||
('header_info', True, 'stats', 'range'),
|
||||
('json_raw', True, 'json', True),
|
||||
('raw_miner_info', True, 'miner_info', True),
|
||||
('stats_only', True, 'no_header', True),
|
||||
],
|
||||
'text': {
|
||||
'desc': 'Display information about a block or range of blocks',
|
||||
|
|
@ -56,6 +57,7 @@ opts_data = {
|
|||
-s, --stats= Display the specified stats (comma-separated list).
|
||||
See AVAILABLE STATS below. The prefixes and special
|
||||
values available to the --fields option are recognized.
|
||||
-S, --stats-only Display stats only. Suppress display of per-block data.
|
||||
""",
|
||||
'notes': """
|
||||
If no block number is specified, the current chain tip is assumed.
|
||||
|
|
@ -117,6 +119,9 @@ EXAMPLES:
|
|||
Display all fields and stats for the last ten blocks:
|
||||
$ {p} -o all -s all +10
|
||||
|
||||
Same as above, but display stats only:
|
||||
$ {p} -o all -s all -S +10
|
||||
|
||||
Display headers-only info for the last 1000 blocks. Speed up execution
|
||||
using the async RPC backend:
|
||||
$ {p} --rpc-backend=aio -H +1000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue