|
|
@@ -21,7 +21,7 @@ mmnode-blocks-info: Display information about a block or range of blocks
|
|
|
"""
|
|
|
|
|
|
from mmgen.common import *
|
|
|
-from mmgen.node_tools.BlocksInfo import BlocksInfo
|
|
|
+from mmgen.node_tools.BlocksInfo import BlocksInfo,JSONBlocksInfo
|
|
|
|
|
|
opts_data = {
|
|
|
'sets': [
|
|
|
@@ -29,6 +29,7 @@ opts_data = {
|
|
|
('hashes', True, 'stats', 'none'),
|
|
|
('stats', 'none', 'stats_only', False),
|
|
|
('stats_only', True, 'no_header', True),
|
|
|
+ ('json', True, 'no_header', True),
|
|
|
],
|
|
|
'text': {
|
|
|
'desc': 'Display information about a block or range of blocks',
|
|
|
@@ -42,6 +43,7 @@ opts_data = {
|
|
|
-h, --help Print this help message
|
|
|
--, --longhelp Print help message for long options (common options)
|
|
|
-H, --hashes Display only block numbers and hashes
|
|
|
+-j, --json Produce JSON output
|
|
|
-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
|
|
|
@@ -122,7 +124,9 @@ async def main():
|
|
|
|
|
|
proto = init_proto_from_opts()
|
|
|
|
|
|
- m = BlocksInfo( cmd_args, opt, await rpc_init(proto) )
|
|
|
+ cls = JSONBlocksInfo if opt.json else BlocksInfo
|
|
|
+
|
|
|
+ m = cls( cmd_args, opt, await rpc_init(proto) )
|
|
|
|
|
|
if not opt.no_header:
|
|
|
m.print_header()
|