plugins: allow plugins to get per-connection deprecated state.
Unfortunately, this is awkward: we just copy through most requests, so we can't easily add a "deprecation" field to each one. So we do a notification if the next command has a different deprecation status than the global one, but that requires opt-in from the plugin. We didn't previously document the subscriptions array, so do that now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Plugins: `deprecated_oneshot` notifiction subscription to change deprecated status for a single command.
This commit is contained in:
@@ -1307,6 +1307,7 @@ static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd,
|
||||
const jsmntok_t *idtok;
|
||||
struct plugin *plugin;
|
||||
struct jsonrpc_request *req;
|
||||
bool cmd_ok;
|
||||
|
||||
if (cmd->mode == CMD_CHECK)
|
||||
return command_param_failed();
|
||||
@@ -1319,6 +1320,15 @@ static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd,
|
||||
idtok = json_get_member(buffer, toks, "id");
|
||||
assert(idtok != NULL);
|
||||
|
||||
/* If they've changed deprecation status for this cmd, tell plugin */
|
||||
cmd_ok = command_deprecated_ok_flag(cmd);
|
||||
if (cmd_ok != cmd->ld->deprecated_ok) {
|
||||
if (!notify_deprecated_oneshot(cmd->ld, plugin, cmd_ok)) {
|
||||
log_debug(plugin->log,
|
||||
"Plugin does not support deprecation setting for cmd %s (id %s)",
|
||||
cmd->json_cmd->name, cmd->id);
|
||||
}
|
||||
}
|
||||
req = jsonrpc_request_start_raw(plugin, cmd->json_cmd->name,
|
||||
cmd->id, plugin->non_numeric_ids,
|
||||
plugin->log,
|
||||
|
||||
Reference in New Issue
Block a user