jsonrpc: probe sites for usage information once, at start.

We store it in a strmap.  This means we call the jsonrpc handler earlier,
so all callers need to call param() before they do anything else; only
json_listaddrs and json_help needed fixing.

Plugins still use '[usage]' for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-04 21:25:42 +10:30
parent e5c80f63d7
commit 5770e0c700
6 changed files with 85 additions and 23 deletions

View File

@@ -610,11 +610,8 @@ static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd,
struct jsonrpc_request *req;
char id[STR_MAX_CHARS(u64)];
if (cmd->mode == CMD_USAGE || cmd->mode == CMD_CHECK) {
/* FIXME! */
cmd->usage = "[params]";
if (cmd->mode == CMD_CHECK)
return command_param_failed();
}
plugin = find_plugin_for_command(cmd);
@@ -675,7 +672,9 @@ static bool plugin_rpcmethod_add(struct plugin *plugin,
cmd->deprecated = false;
cmd->dispatch = plugin_rpcmethod_dispatch;
if (!jsonrpc_command_add(plugin->plugins->ld->jsonrpc, cmd)) {
if (!jsonrpc_command_add(plugin->plugins->ld->jsonrpc, cmd,
/* FIXME */
"[params]")) {
log_broken(plugin->log,
"Could not register method \"%s\", a method with "
"that name is already registered",