mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-16 12:24:22 +01:00
json-rpc: make commands return 'struct command_result *'.
Usually, this means they return 'command_param_failed()' if param() fails, and changing 'command_success(); return;' to 'return command_success()'. Occasionally, it's more complex: there's a command_its_complicated() for the case where we can't exactly determine what the status is, but it should be considered a last resort. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -656,9 +656,10 @@ static struct plugin *find_plugin_for_command(struct command *cmd)
|
||||
abort();
|
||||
}
|
||||
|
||||
static void plugin_rpcmethod_dispatch(struct command *cmd, const char *buffer,
|
||||
const jsmntok_t *toks,
|
||||
const jsmntok_t *params UNNEEDED)
|
||||
static struct command_result *plugin_rpcmethod_dispatch(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *toks,
|
||||
const jsmntok_t *params UNNEEDED)
|
||||
{
|
||||
const jsmntok_t *idtok;
|
||||
struct plugin *plugin;
|
||||
@@ -668,7 +669,7 @@ static void plugin_rpcmethod_dispatch(struct command *cmd, const char *buffer,
|
||||
if (cmd->mode == CMD_USAGE) {
|
||||
/* FIXME! */
|
||||
cmd->usage = "[params]";
|
||||
return;
|
||||
return command_param_failed();
|
||||
}
|
||||
|
||||
plugin = find_plugin_for_command(cmd);
|
||||
@@ -683,7 +684,7 @@ static void plugin_rpcmethod_dispatch(struct command *cmd, const char *buffer,
|
||||
json_stream_forward_change_id(req->stream, buffer, toks, idtok, id);
|
||||
plugin_request_queue(plugin, req);
|
||||
|
||||
command_still_pending(cmd);
|
||||
return command_still_pending(cmd);
|
||||
}
|
||||
|
||||
static bool plugin_rpcmethod_add(struct plugin *plugin,
|
||||
|
||||
Reference in New Issue
Block a user