Skip to content

Commit

Permalink
libplugin: Add 'getmanifest' 'dynamic' field
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior authored and cdecker committed Aug 3, 2019
1 parent f57f068 commit 017ee7c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/autoclean.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions plugins/libplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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, ...)
{
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions plugins/libplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 changes: 1 addition & 1 deletion plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 017ee7c

Please sign in to comment.