libplugin: remove command_success_str function.

As mentioned in previous commits: "result" must be an object,
and anything else is an antipattern.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-05-26 15:14:01 +09:30
parent 97b52ed8c3
commit a4c7ff0f10
2 changed files with 1 additions and 21 deletions

View File

@ -345,21 +345,6 @@ command_success(struct command *cmd, const struct json_out *result)
return command_complete(cmd, js);
}
struct command_result *WARN_UNUSED_RESULT
command_success_str(struct command *cmd, const char *str)
{
struct json_stream *js = jsonrpc_stream_start(cmd);
if (str)
json_add_string(js, "result", str);
else {
/* Use an empty object if they don't want anything. */
json_object_start(js, "result");
json_object_end(js);
}
return command_complete(cmd, js);
}
struct command_result *command_done_err(struct command *cmd,
errcode_t code,
const char *errmsg,
@ -904,7 +889,7 @@ static struct command_result *handle_init(struct command *cmd,
if (with_rpc)
io_new_conn(p, p->rpc_conn->fd, rpc_conn_init, p);
return command_success_str(cmd, NULL);
return command_success(cmd, json_out_obj(cmd, NULL, NULL));
}
char *u64_option(const char *arg, u64 *i)

View File

@ -181,11 +181,6 @@ struct command_result *command_err_raw(struct command *cmd,
struct command_result *WARN_UNUSED_RESULT
command_success(struct command *cmd, const struct json_out *result);
/* Simple version where we just want to send a string, or NULL means an empty
* result object. @cmd cannot be NULL. */
struct command_result *WARN_UNUSED_RESULT
command_success_str(struct command *cmd, const char *str);
/* End a hook normally (with "result": "continue") */
struct command_result *WARN_UNUSED_RESULT
command_hook_success(struct command *cmd);