libplugin: Add notification topics to plugin_main

This commit is contained in:
Christian Decker 2021-04-28 17:28:27 +02:00 committed by Rusty Russell
parent e02e972729
commit f963a6a551
11 changed files with 21 additions and 8 deletions

View File

@ -91,7 +91,7 @@ int main(int argc, char *argv[])
{
setup_locale();
plugin_main(argv, init, PLUGIN_STATIC, true, NULL, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0,
NULL, 0, NULL, 0, NULL, 0,
plugin_option("autocleaninvoice-cycle",
"string",
"Perform cleanup of expired invoices every"

View File

@ -972,7 +972,7 @@ int main(int argc, char *argv[])
plugin_main(argv, init, PLUGIN_STATIC, false /* Do not init RPC on startup*/,
NULL, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0,
NULL, 0, NULL, 0, NULL, 0,
plugin_option("bitcoin-datadir",
"string",
"-datadir arg for bitcoin-cli",

View File

@ -1389,6 +1389,7 @@ int main(int argc, char *argv[])
/* No notifications */
NULL, 0,
hooks, ARRAY_SIZE(hooks),
NULL, 0,
/* No options */
NULL);
}

View File

@ -388,5 +388,5 @@ int main(int argc, char *argv[])
plugin_main(argv, init, PLUGIN_STATIC, true, &features, commands,
ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks),
NULL);
NULL, 0, NULL);
}

View File

@ -92,7 +92,8 @@ struct plugin {
* initialization or need to recover from a disconnect. */
const char *rpc_location;
char **notification_topics;
const char **notif_topics;
size_t num_notif_topics;
};
/* command_result is mainly used as a compile-time check to encourage you
@ -1318,6 +1319,8 @@ static struct plugin *new_plugin(const tal_t *ctx,
size_t num_notif_subs,
const struct plugin_hook *hook_subs,
size_t num_hook_subs,
const char **notif_topics,
size_t num_notif_topics,
va_list ap)
{
const char *optname;
@ -1355,6 +1358,8 @@ static struct plugin *new_plugin(const tal_t *ctx,
p->commands = commands;
p->num_commands = num_commands;
p->notif_topics = notif_topics;
p->num_notif_topics = num_notif_topics;
p->notif_subs = notif_subs;
p->num_notif_subs = num_notif_subs;
p->hook_subs = hook_subs;
@ -1387,6 +1392,8 @@ void plugin_main(char *argv[],
size_t num_notif_subs,
const struct plugin_hook *hook_subs,
size_t num_hook_subs,
const char **notif_topics,
size_t num_notif_topics,
...)
{
struct plugin *plugin;
@ -1399,10 +1406,10 @@ void plugin_main(char *argv[],
/* Note this already prints to stderr, which is enough for now */
daemon_setup(argv[0], NULL, NULL);
va_start(ap, num_hook_subs);
va_start(ap, num_notif_topics);
plugin = new_plugin(NULL, init, restartability, init_rpc, features, commands,
num_commands, notif_subs, num_notif_subs, hook_subs,
num_hook_subs, ap);
num_hook_subs, notif_topics, num_notif_topics, ap);
va_end(ap);
setup_command_usage(plugin);

View File

@ -293,6 +293,8 @@ void NORETURN LAST_ARG_NULL plugin_main(char *argv[],
size_t num_notif_subs,
const struct plugin_hook *hook_subs,
size_t num_hook_subs,
const char **notif_topics,
size_t num_notif_topics,
...);
struct listpeers_channel {

View File

@ -722,5 +722,5 @@ int main(int argc, char *argv[])
setenv("TZ", "", 1);
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands,
ARRAY_SIZE(commands), NULL, 0, hooks, ARRAY_SIZE(hooks),
NULL);
NULL, 0, NULL);
}

View File

@ -2198,6 +2198,7 @@ int main(int argc, char *argv[])
setup_locale();
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL, commands,
ARRAY_SIZE(commands), NULL, 0, NULL, 0,
NULL, 0,
plugin_option("disable-mpp", "flag",
"Disable multi-part payments.",
flag_option, &disablempp),

View File

@ -39,6 +39,7 @@ int main(int argc, char **argv)
commands, tal_count(commands),
notifs, tal_count(notifs),
NULL, 0,
NULL, 0, /* Notification topics */
NULL);
tal_free(owner);

View File

@ -553,5 +553,5 @@ int main(int argc, char *argv[])
{
setup_locale();
plugin_main(argv, NULL, PLUGIN_RESTARTABLE, true, NULL, commands,
ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL);
ARRAY_SIZE(commands), NULL, 0, NULL, 0, NULL, 0, NULL);
}

View File

@ -146,6 +146,7 @@ int main(int argc, char *argv[])
plugin_main(argv, init, PLUGIN_RESTARTABLE, true, NULL,
commands, ARRAY_SIZE(commands),
notifs, ARRAY_SIZE(notifs), hooks, ARRAY_SIZE(hooks),
NULL, 0, /* Notification topics we publish */
plugin_option("name",
"string",
"Who to say hello to.",