|
@@ -25,11 +25,10 @@ from mmgen.node_tools.BlocksInfo import BlocksInfo
|
|
|
|
|
|
opts_data = {
|
|
|
'sets': [
|
|
|
- ('raw_miner_info', True, 'miner_info', True),
|
|
|
- ('summary', True, 'raw_miner_info', False),
|
|
|
- ('summary', True, 'miner_info', False),
|
|
|
- ('hashes', True, 'fields', 'block,hash'),
|
|
|
- ('hashes', True, 'no_summary', True),
|
|
|
+ ('hashes', True, 'fields', 'block,hash'),
|
|
|
+ ('hashes', True, 'stats', 'none'),
|
|
|
+ ('stats', 'none', 'stats_only', False),
|
|
|
+ ('stats_only', True, 'no_header', True),
|
|
|
],
|
|
|
'text': {
|
|
|
'desc': 'Display information about a block or range of blocks',
|
|
@@ -42,16 +41,18 @@ opts_data = {
|
|
|
'options': """
|
|
|
-h, --help Print this help message
|
|
|
--, --longhelp Print help message for long options (common options)
|
|
|
--D, --no-diff-stats Omit difficulty adjustment stats from summary
|
|
|
-H, --hashes Display only block numbers and hashes
|
|
|
-m, --miner-info Display miner info in coinbase transaction
|
|
|
-M, --raw-miner-info Display miner info in uninterpreted form
|
|
|
-n, --no-header Don’t print the column header
|
|
|
--o, --fields= Display the specified fields (comma-separated list)
|
|
|
+-o, --fields= Display the specified fields (comma-separated list).
|
|
|
See AVAILABLE FIELDS below. If the first character
|
|
|
- is '+', fields are appended to the defaults.
|
|
|
--s, --summary Print the summary only
|
|
|
--S, --no-summary Don’t print the summary
|
|
|
+ is '+', specified fields are added to the defaults.
|
|
|
+-s, --stats= Display the specified stats (comma-separated list).
|
|
|
+ See AVAILABLE STATS below. If the first character is
|
|
|
+ '+', specified stats are added to the defaults. Use
|
|
|
+ 'none' to disable, or 'all' for all available stats.
|
|
|
+-S, --stats-only Display stats only. Skip display of per-block data.
|
|
|
""",
|
|
|
'notes': """
|
|
|
If no block number is specified, the current block is assumed. The string
|
|
@@ -65,6 +66,8 @@ All fee fields except for 'totalfee' are in satoshis per virtual byte.
|
|
|
|
|
|
AVAILABLE FIELDS: {f}
|
|
|
|
|
|
+AVAILABLE STATS: {s}
|
|
|
+
|
|
|
EXAMPLES:
|
|
|
|
|
|
# Display info for current block:
|
|
@@ -99,9 +102,13 @@ EXAMPLES:
|
|
|
# multiplication is allowed in the nBlocks spec:
|
|
|
{p} +144*14+144
|
|
|
|
|
|
+ # Display only range stats for the last ten blocks:
|
|
|
+ {p} -s range -S +10
|
|
|
+
|
|
|
This program requires a txindex-enabled daemon for correct operation.
|
|
|
""".format(
|
|
|
f = fmt_list(BlocksInfo.fields,fmt='bare'),
|
|
|
+ s = fmt_list(BlocksInfo.all_stats,fmt='bare'),
|
|
|
p = g.prog_name )
|
|
|
}
|
|
|
}
|
|
@@ -116,17 +123,18 @@ async def main():
|
|
|
from mmgen.rpc import rpc_init
|
|
|
m = BlocksInfo( cmd_args, opt, await rpc_init(proto) )
|
|
|
|
|
|
- if not (opt.summary or opt.no_header):
|
|
|
+ if not opt.no_header:
|
|
|
m.print_header()
|
|
|
|
|
|
await m.run()
|
|
|
|
|
|
- if m.last and not opt.no_summary:
|
|
|
- Msg('')
|
|
|
- await m.print_range_stats()
|
|
|
-
|
|
|
- if not opt.no_diff_stats:
|
|
|
- Msg('')
|
|
|
- await m.print_diff_stats()
|
|
|
+ if m.last and m.stats:
|
|
|
+ for i,stat in enumerate(m.stats):
|
|
|
+ if stat == 'diff': # Display diff stats by default only if user-requested range ends with chain tip
|
|
|
+ if not opt.stats and m.last != m.tip:
|
|
|
+ continue
|
|
|
+ if not (opt.stats_only and i == 0):
|
|
|
+ Msg('')
|
|
|
+ await m.print_stats(stat)
|
|
|
|
|
|
run_session(main())
|