From 017ee7c916047c1a607057bdab973b94b98e88b0 Mon Sep 17 00:00:00 2001 From: darosior Date: Mon, 29 Jul 2019 13:46:48 +0200 Subject: [PATCH] libplugin: Add 'getmanifest' 'dynamic' field --- plugins/autoclean.c | 2 +- plugins/libplugin.c | 7 +++++-- plugins/libplugin.h | 6 ++++++ plugins/pay.c | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plugins/autoclean.c b/plugins/autoclean.c index 8ef8b8ab5..7d17e5c1c 100644 --- a/plugins/autoclean.c +++ b/plugins/autoclean.c @@ -90,7 +90,7 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, commands, ARRAY_SIZE(commands), + plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), plugin_option("autocleaninvoice-cycle", "string", "Perform cleanup of expired invoices every" diff --git a/plugins/libplugin.c b/plugins/libplugin.c index e365e28b1..2720b598d 100644 --- a/plugins/libplugin.c +++ b/plugins/libplugin.c @@ -473,7 +473,8 @@ static struct command_result * handle_getmanifest(struct command *getmanifest_cmd, const struct plugin_command *commands, size_t num_commands, - const struct plugin_option *opts) + const struct plugin_option *opts, + const enum plugin_restartability restartability) { struct json_out *params = json_out_new(tmpctx); @@ -501,6 +502,7 @@ handle_getmanifest(struct command *getmanifest_cmd, json_out_end(params, '}'); } json_out_end(params, ']'); + json_out_addstr(params, "dynamic", restartability == PLUGIN_RESTARTABLE ? "true" : "false"); json_out_end(params, '}'); json_out_finished(params); @@ -699,6 +701,7 @@ void plugin_log(enum log_level l, const char *fmt, ...) void plugin_main(char *argv[], void (*init)(struct plugin_conn *rpc), + const enum plugin_restartability restartability, const struct plugin_command *commands, size_t num_commands, ...) { @@ -749,7 +752,7 @@ void plugin_main(char *argv[], plugin_err("Expected getmanifest not %s", cmd->methodname); membuf_consume(&request_conn.mb, reqlen); - handle_getmanifest(cmd, commands, num_commands, opts); + handle_getmanifest(cmd, commands, num_commands, opts, restartability); cmd = read_json_request(tmpctx, &request_conn, &rpc_conn, ¶ms, &reqlen); diff --git a/plugins/libplugin.h b/plugins/libplugin.h index 3be2ff319..6c92f7970 100644 --- a/plugins/libplugin.h +++ b/plugins/libplugin.h @@ -16,6 +16,11 @@ struct plugin_conn; extern bool deprecated_apis; +enum plugin_restartability { + PLUGIN_STATIC, + PLUGIN_RESTARTABLE +}; + /* Create an array of these, one for each command you support. */ struct plugin_command { const char *name; @@ -148,6 +153,7 @@ char *charp_option(const char *arg, char **p); /* The main plugin runner: append with 0 or more plugin_option(), then NULL. */ void NORETURN LAST_ARG_NULL plugin_main(char *argv[], void (*init)(struct plugin_conn *rpc), + const enum plugin_restartability restartability, const struct plugin_command *commands, size_t num_commands, ...); #endif /* LIGHTNING_PLUGINS_LIBPLUGIN_H */ diff --git a/plugins/pay.c b/plugins/pay.c index 3b3bcf50d..1653a3980 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -1311,5 +1311,5 @@ static const struct plugin_command commands[] = { { int main(int argc, char *argv[]) { setup_locale(); - plugin_main(argv, init, commands, ARRAY_SIZE(commands), NULL); + plugin_main(argv, init, PLUGIN_RESTARTABLE, commands, ARRAY_SIZE(commands), NULL); }