new MMGEN_BLACKLIST_DAEMONS environment var

This commit is contained in:
The MMGen Project 2022-06-13 17:30:22 +00:00
commit 84ff9f643a
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 20 additions and 2 deletions

View file

@ -26,7 +26,7 @@ from collections import namedtuple
from .globalvars import g
from .color import set_vt100
from .util import msg,Msg_r,ymsg,die,remove_dups
from .util import msg,Msg_r,ymsg,die,remove_dups,oneshot_warning
from .flags import *
_dd = namedtuple('daemon_data',['coind_name','coind_version','coind_version_str']) # latest tested version
@ -274,12 +274,25 @@ class CoinDaemon(Daemon):
def all_daemon_ids(cls):
return [i for coin in cls.coins for i in cls.coins[coin].daemon_ids]
class warn_blacklisted(oneshot_warning):
color = 'yellow'
message = 'blacklisted daemon: {!r}'
@classmethod
def get_daemon_ids(cls,coin):
ret = cls.coins[coin].daemon_ids
if 'erigon' in ret and not g.enable_erigon:
ret.remove('erigon')
if g.blacklist_daemons:
blacklist = g.blacklist_daemons.split()
def gen():
for daemon_id in ret:
if daemon_id in blacklist:
cls.warn_blacklisted(div=daemon_id,fmt_args=[daemon_id])
else:
yield daemon_id
ret = list(gen())
return ret
@classmethod

View file

@ -1 +1 @@
13.2.dev7
13.2.dev8

View file

@ -146,6 +146,7 @@ class GlobalContext(Lockable):
data_dir_root,data_dir,cfg_file = (None,None,None)
daemon_data_dir = '' # set by user
daemon_id = ''
blacklist_daemons = ''
# must match CoinProtocol.coins
core_coins = ('btc','bch','ltc','eth','etc','zec','xmr')
@ -243,6 +244,7 @@ class GlobalContext(Lockable):
'MMGEN_TEST_SUITE',
'MMGEN_TEST_SUITE_DETERMINISTIC',
'MMGEN_TEST_SUITE_POPEN_SPAWN',
'MMGEN_BLACKLIST_DAEMONS',
'MMGEN_BOGUS_SEND',
'MMGEN_DEBUG',
'MMGEN_DEBUG_OPTS',

View file

@ -171,6 +171,9 @@ opts.UserOpts._reset_ok += ('no_daemon_autostart','names','no_timings','exit_aft
# step 2: opts.init will create new data_dir in ./test (if not skipping_deps)
usr_args = opts.init(opts_data)
if opt.daemon_id and opt.daemon_id in g.blacklist_daemons.split():
die(0,f'test.py: daemon {opt.daemon_id!r} blacklisted, exiting')
network_id = g.coin.lower() + ('_tn' if opt.testnet else '')
from mmgen.protocol import init_proto_from_opts