Browse Source

libplugin: Add 'getmanifest' 'dynamic' field

pull/2938/head
darosior 5 years ago
committed by Christian Decker
parent
commit
017ee7c916
  1. 2
      plugins/autoclean.c
  2. 7
      plugins/libplugin.c
  3. 6
      plugins/libplugin.h
  4. 2
      plugins/pay.c

2
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"

7
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,
&params, &reqlen);

6
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 */

2
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);
}

Loading…
Cancel
Save