Browse Source

lightningd/plugin.c: Add a `--dev-builtin-plugins-unimportant` for developers who want to mess around with the builtin plugins.

bump-pyln-proto
ZmnSCPxj jxPCSnmZ 4 years ago
committed by neil saitug
parent
commit
1ded3fc52f
  1. 4
      lightningd/options.c
  2. 24
      lightningd/plugin.c
  3. 5
      lightningd/plugin.h
  4. 6
      tests/test_plugin.py

4
lightningd/options.c

@ -566,6 +566,10 @@ static void dev_register_opts(struct lightningd *ld)
opt_register_noarg("--dev-no-version-checks", opt_set_bool,
&ld->dev_no_version_checks,
"Skip calling subdaemons with --version on startup");
opt_register_early_noarg("--dev-builtin-plugins-unimportant",
opt_set_bool,
&ld->plugins->dev_builtin_plugins_unimportant,
"Make builtin plugins unimportant so you can plugin stop them.");
}
#endif /* DEVELOPER */

24
lightningd/plugin.c

@ -57,6 +57,9 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
p->json_cmds = tal_arr(p, struct command *, 0);
p->blacklist = tal_arr(p, const char *, 0);
p->shutdown = false;
#if DEVELOPER
p->dev_builtin_plugins_unimportant = false;
#endif /* DEVELOPER */
uintmap_init(&p->pending_requests);
memleak_add_helper(p, memleak_help_pending_requests);
@ -1328,6 +1331,27 @@ void plugins_init(struct plugins *plugins)
plugins->default_dir = path_join(plugins, plugins->ld->config_basedir, "plugins");
plugins_add_default_dir(plugins);
#if DEVELOPER
if (plugins->dev_builtin_plugins_unimportant) {
size_t i;
log_debug(plugins->log, "Builtin plugins now unimportant");
/* For each builtin plugin, check for a matching plugin
* and make it unimportant. */
for (i = 0; list_of_builtin_plugins[i]; ++i) {
const char *name = list_of_builtin_plugins[i];
struct plugin *p;
list_for_each(&plugins->plugins, p, list) {
if (plugin_paths_match(p->cmd, name)) {
p->important = false;
break;
}
}
}
}
#endif /* DEVELOPER */
setenv("LIGHTNINGD_PLUGIN", "1", 1);
setenv("LIGHTNINGD_VERSION", version(), 1);

5
lightningd/plugin.h

@ -110,6 +110,11 @@ struct plugins {
/* Whether we are shutting down (`plugins_free` is called) */
bool shutdown;
#if DEVELOPER
/* Whether builtin plugins should be overridden as unimportant. */
bool dev_builtin_plugins_unimportant;
#endif /* DEVELOPER */
};
/* The value of a plugin option, which can have different types.

6
tests/test_plugin.py

@ -1596,3 +1596,9 @@ def test_important_plugin(node_factory):
# node should die as well.
n.daemon.wait_for_log('pay: Plugin marked as important, shutting down lightningd')
wait_for(lambda: not n.daemon.running)
@unittest.skipIf(not DEVELOPER, "tests developer-only option.")
def test_dev_builtin_plugins_unimportant(node_factory):
n = node_factory.get_node(options={"dev-builtin-plugins-unimportant": None})
n.rpc.plugin_stop(plugin="pay")

Loading…
Cancel
Save