Skip to content

Commit

Permalink
libplugin: remove global deprecated_apis flag.
Browse files Browse the repository at this point in the history
And we don't need to handle 0.9 lightningd which didn't include
allow-deprecated-apis in getmanifest call.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jan 25, 2024
1 parent 1c63b21 commit 31c081d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
27 changes: 12 additions & 15 deletions plugins/libplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#define READ_CHUNKSIZE 4096

bool deprecated_apis;

struct plugin_timer {
struct timer timer;
void (*cb)(void *cb_arg);
Expand All @@ -48,7 +46,10 @@ struct plugin {
/* Are we in developer mode? */
bool developer;

/* Is this command overriding the global deprecated_apis? */
/* Global deprecations enabled? */
bool deprecated_ok;

/* Is this command overriding global deprecated_ok? */
bool *deprecated_ok_override;

/* to append to all our command ids */
Expand Down Expand Up @@ -167,7 +168,7 @@ bool command_deprecated_in_nocmd_ok(struct plugin *plugin,
const char *depr_start,
const char *depr_end)
{
return deprecated_ok(deprecated_apis,
return deprecated_ok(plugin->deprecated_ok,
name,
depr_start, depr_end,
plugin->beglist,
Expand Down Expand Up @@ -1001,18 +1002,14 @@ handle_getmanifest(struct command *getmanifest_cmd,
{
struct json_stream *params = jsonrpc_stream_success(getmanifest_cmd);
struct plugin *p = getmanifest_cmd->plugin;
const jsmntok_t *dep;
bool has_shutdown_notif;

/* This was added post 0.9.0 */
dep = json_get_member(buf, getmanifest_params, "allow-deprecated-apis");
if (!dep)
deprecated_apis = true;
else {
if (!json_to_bool(buf, dep, &deprecated_apis))
plugin_err(p, "Invalid allow-deprecated-apis '%.*s'",
json_tok_full_len(dep),
json_tok_full(buf, dep));
if (json_scan(tmpctx, buf, getmanifest_params,
"{allow-deprecated-apis:%}",
JSON_SCAN(json_to_bool, &p->deprecated_ok)) != NULL) {
plugin_err(p, "Invalid allow-deprecated-apis in '%.*s'",
json_tok_full_len(getmanifest_params),
json_tok_full(buf, getmanifest_params));
}

json_array_start(params, "options");
Expand Down Expand Up @@ -1676,7 +1673,7 @@ bool command_deprecated_ok_flag(const struct command *cmd)
{
if (cmd->plugin->deprecated_ok_override)
return *cmd->plugin->deprecated_ok_override;
return deprecated_apis;
return cmd->plugin->deprecated_ok;
}

static void ld_command_handle(struct plugin *plugin,
Expand Down
2 changes: 0 additions & 2 deletions plugins/libplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct htable;
struct plugin;
struct rpc_conn;

extern bool deprecated_apis;

enum plugin_restartability {
PLUGIN_STATIC,
PLUGIN_RESTARTABLE
Expand Down

0 comments on commit 31c081d

Please sign in to comment.