From 84ff9f643a6dbab38c678c2c3f7b3e5e743736a0 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 13 Jun 2022 17:30:22 +0000 Subject: [PATCH] new MMGEN_BLACKLIST_DAEMONS environment var --- mmgen/daemon.py | 15 ++++++++++++++- mmgen/data/version | 2 +- mmgen/globalvars.py | 2 ++ test/test.py | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/mmgen/daemon.py b/mmgen/daemon.py index c9f62535..dd5cd891 100755 --- a/mmgen/daemon.py +++ b/mmgen/daemon.py @@ -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 diff --git a/mmgen/data/version b/mmgen/data/version index 5f22f526..34a9c281 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -13.2.dev7 +13.2.dev8 diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index 6a27ca8d..8ed45ac2 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -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', diff --git a/test/test.py b/test/test.py index b066590b..6206d330 100755 --- a/test/test.py +++ b/test/test.py @@ -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