minor changes and fixes

This commit is contained in:
The MMGen Project 2021-08-08 19:14:52 +00:00
commit 92ebb62490
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 31 additions and 14 deletions

View file

@ -640,14 +640,19 @@ class ethereum_daemon(CoinDaemon):
chain_subdirs = _nw('ethereum','goerli','DevelopmentChain')
base_rpc_port = 8545 # same for all networks!
base_p2p_port = 30303 # same for all networks!
daemon_port_offset = 100
network_port_offsets = _nw(0,10,20)
@property
def port_offset(self):
return (
(self.coins['ETH'].daemon_ids + self.coins['ETC'].daemon_ids).index(self.id) * 100
+ getattr(self.network_port_offsets,self.network)
)
def __init__(self,*args,**kwargs):
if not hasattr(ethereum_daemon,'all_daemons'):
ethereum_daemon.all_daemons = get_subclasses(ethereum_daemon,names=True)
self.port_offset = (
self.all_daemons.index(self.id+'_daemon') * self.daemon_port_offset
+ getattr(self.network_port_offsets,self.network) )
return super().__init__(*args,**kwargs)
def get_rpc_port(self):
return self.base_rpc_port + self.port_offset
@ -786,7 +791,7 @@ class erigon_rpcdaemon(RPCDaemon):
self.daemon_args = list_gen(
['--verbosity=0'],
[f'--private.api.addr=127.0.0.1:{private_port}'],
[f'--http.port={self.rpc_port}'],
[f'--datadir={self.datadir}', self.network != 'regtest'],
['--http.api=eth,web3,txpool'],
[f'--http.port={self.rpc_port}'],
)

View file

@ -725,9 +725,9 @@ class daemon_warning(oneshot_warning):
color = 'yellow'
message = 'ignoring unsupported {} daemon version at user request'
def handle_unsupported_daemon_version(rpc,proto,ignore_daemon_version):
if ignore_daemon_version or proto.ignore_daemon_version or g.ignore_daemon_version:
daemon_warning('version',div=proto.name,fmt_args=[rpc.daemon.coind_name])
def handle_unsupported_daemon_version(rpc,name,warn_only):
if warn_only:
daemon_warning('version',div=name,fmt_args=[rpc.daemon.coind_name])
else:
name = rpc.daemon.coind_name
rdie(1,'\n'+fmt(f"""
@ -755,7 +755,10 @@ async def rpc_init(proto,backend=None,daemon=None,ignore_daemon_version=False):
backend = backend or opt.rpc_backend )
if rpc.daemon_version > rpc.daemon.coind_version:
handle_unsupported_daemon_version(rpc,proto,ignore_daemon_version)
handle_unsupported_daemon_version(
rpc,
proto.name,
ignore_daemon_version or proto.ignore_daemon_version or g.ignore_daemon_version )
if rpc.chain not in proto.chain_names:
raise RPCChainMismatch('\n'+fmt(f"""

View file

@ -731,8 +731,6 @@ def get_data_from_file(infile,desc='data',dash=False,silent=False,binary=False,q
return data
passwd_files_used = {}
class oneshot_warning:
def __init__(self,wcls,div=None,fmt_args=[]):
@ -754,6 +752,8 @@ class oneshot_warning:
do_warning()
attr.append(div)
passwd_files_used = {}
def pwfile_reuse_warning(passwd_file):
if passwd_file in passwd_files_used:
qmsg(f'Reusing passphrase from file {passwd_file!r} at user request')
@ -877,6 +877,14 @@ def format_par(s,indent=0,width=80,as_list=False):
lines.append(' '*indent + line)
return lines if as_list else '\n'.join(lines) + '\n'
def get_subclasses(cls,names=False):
def gen(cls):
for i in cls.__subclasses__():
yield i
for j in gen(i):
yield j
return tuple((c.__name__ for c in gen(cls)) if names else gen(cls))
def altcoin_subclass(cls,proto,mod_dir):
"""
magic module loading and class retrieval

View file

@ -342,7 +342,8 @@ f_xmr='Monero xmrwallet tests completed'
i_eth='Ethereum'
s_eth='Testing transaction and tracking wallet operations for Ethereum'
t_eth="
- $test_py --coin=eth ethdev
- $test_py --coin=eth --daemon-id=openethereum ethdev
- $test_py --coin=eth --daemon-id=geth ethdev
"
f_eth='Ethereum tests completed'