Browse Source

use mmgen launcher; init fixes; blocks-info: improve miner string parsing

The MMGen Project 2 years ago
parent
commit
3d62ff8211

+ 2 - 0
README.md

@@ -17,6 +17,8 @@ Then,
     $ python3 -m build --no-isolation
     $ python3 -m pip install --user dist/*.whl
 
+Also make sure that `~/.local/bin` is in `PATH`.
+
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
 [**Forum**][4] |

+ 17 - 0
cmds/mmnode-blocks-info

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-blocks-info: Display information about a block or range of blocks
+"""
+
+from mmgen.main import launch
+
+launch('blocks_info',package='mmgen_node_tools')

+ 17 - 0
cmds/mmnode-feeview

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-feeview: Visualize the fee structure of a node’s mempool
+"""
+
+from mmgen.main import launch
+
+launch('feeview',package='mmgen_node_tools')

+ 17 - 0
cmds/mmnode-halving-calculator

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-halving-calculator: Estimate date(s) of future block subsidy halving(s)
+"""
+
+from mmgen.main import launch
+
+launch('halving_calculator',package='mmgen_node_tools')

+ 17 - 0
cmds/mmnode-netrate

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-netrate: Bitcoin daemon network rate monitor
+"""
+
+from mmgen.main import launch
+
+launch('netrate',package='mmgen_node_tools')

+ 17 - 0
cmds/mmnode-peerblocks

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-peerblocks: List blocks in flight, disconnect stalling nodes
+"""
+
+from mmgen.main import launch
+
+launch('peerblocks',package='mmgen_node_tools')

+ 17 - 0
cmds/mmnode-txfind

@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
+# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
+# Licensed under the GNU General Public License, Version 3:
+#   https://www.gnu.org/licenses
+# Public project repositories:
+#   https://github.com/mmgen/mmgen https://github.com/mmgen/mmgen-node-tools
+#   https://gitlab.com/mmgen/mmgen https://gitlab.com/mmgen/mmgen-node-tools
+
+"""
+mmnode-txfind: Find a transaction in the blockchain or mempool
+"""
+
+from mmgen.main import launch
+
+launch('txfind',package='mmgen_node_tools')

+ 11 - 2
mmgen_node_tools/BlocksInfo.py

@@ -226,15 +226,18 @@ class BlocksInfo:
 		)
 
 		if 'miner' in self.fnames:
+			# capturing parens must contain only ASCII chars!
 			self.miner_pats = [re.compile(pat) for pat in (
 				rb'`/([_a-zA-Z0-9&. #/-]+)/',
-				rb'[\xe3\xe4\xe5][\^/](.*?)\xfa',
+				rb'[\xe3\xe4\xe5][\^/]([\x20-\x7e]+?)\xfa',
 				rb'([a-zA-Z0-9&. -]+/Mined by [a-zA-Z0-9. ]+)',
 				rb'\x08/(.*Mined by [a-zA-Z0-9. ]+)',
 				rb'Mined by ([a-zA-Z0-9. ]+)',
 				rb'[`]([_a-zA-Z0-9&. #/-]+)[/\xfa]',
+				rb'([\x20-\x7e]{9,})',
 				rb'[/^]([a-zA-Z0-9&. #/-]{5,})',
 				rb'[/^]([_a-zA-Z0-9&. #/-]+)/',
+				rb'^\x03...\W{0,5}([\\_a-zA-Z0-9&. #/-]+)[/\\]',
 			)]
 
 		self.block_data = namedtuple('block_data',self.fnames)
@@ -428,10 +431,16 @@ class BlocksInfo:
 			if self.opt.raw_miner_info:
 				return repr(cb)
 			else:
+				trmap_in = {
+					'\\': ' ',
+					'/': ' ',
+					',': ' ',
+				}
+				trmap = { ord(a):b for a,b in trmap_in.items() }
 				for pat in self.miner_pats:
 					m = pat.search(cb)
 					if m:
-						return ''.join(chr(b) for b in m[1] if 31 < b < 127).strip('^').strip('/').replace('/',' ')
+						return re.sub( r'\s+', ' ', m[1].decode().strip('^').translate(trmap).strip() )
 			return ''
 
 	def print_header(self):

+ 1 - 1
mmgen_node_tools/Sound.py

@@ -1 +1 @@
-3.0.0
+3.1.dev1

+ 1 - 1
mmnode-blocks-info → mmgen_node_tools/main_blocks_info.py

@@ -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,JSONBlocksInfo
+from .BlocksInfo import BlocksInfo,JSONBlocksInfo
 
 opts_data = {
 	'sets': [

+ 6 - 2
mmnode-feeview → mmgen_node_tools/main_feeview.py

@@ -125,9 +125,12 @@ def create_data(coin_amt,mempool):
 				break
 
 	# remove empty top brackets:
-	while out[-1].tx_bytes == 0:
+	while out and out[-1].tx_bytes == 0:
 		out.pop()
 
+	if not out:
+		die(1,'No data!')
+
 	out.reverse() # cumulative totals and display are top-down
 
 	# calculate cumulative byte totals, filter rows:
@@ -197,7 +200,7 @@ def gen_body(data):
 async def main():
 
 	from mmgen.protocol import init_proto_from_opts
-	proto = init_proto_from_opts()
+	proto = init_proto_from_opts(need_amt=True)
 
 	from mmgen.rpc import rpc_init
 	c = await rpc_init(proto)
@@ -210,6 +213,7 @@ async def main():
 		log(mempool,'mempool.json')
 
 	data = create_data(proto.coin_amt,mempool)
+
 	(do_pager if opt.pager else print)(
 		'\n'.join(gen_header(c.host,await c.call('getblockcount'))) + '\n' +
 		'\n'.join(gen_body(data))

+ 1 - 1
mmnode-halving-calculator → mmgen_node_tools/main_halving_calculator.py

@@ -62,7 +62,7 @@ def time_diff_warning(t_diff):
 async def main():
 
 	from mmgen.protocol import init_proto_from_opts
-	proto = init_proto_from_opts()
+	proto = init_proto_from_opts(need_amt=True)
 
 	from mmgen.rpc import rpc_init
 	c = await rpc_init(proto)

+ 0 - 0
mmnode-netrate → mmgen_node_tools/main_netrate.py


+ 0 - 0
mmnode-peerblocks → mmgen_node_tools/main_peerblocks.py


+ 0 - 0
mmnode-txfind → mmgen_node_tools/main_txfind.py


+ 6 - 6
setup.cfg

@@ -23,14 +23,14 @@ python_requires = >=3.7
 include_package_data = True
 
 install_requires =
-	mmgen>=13.0.0
+	mmgen>=13.1.dev19
 
 packages =
 	mmgen_node_tools
 
 scripts =
-	mmnode-blocks-info
-	mmnode-feeview
-	mmnode-halving-calculator
-	mmnode-netrate
-	mmnode-peerblocks
+	cmds/mmnode-blocks-info
+	cmds/mmnode-feeview
+	cmds/mmnode-halving-calculator
+	cmds/mmnode-netrate
+	cmds/mmnode-peerblocks