jsonrpc: declare up front whether a response is success or fail.

Such an API is required for when we stream it directly.  Almost all our
handlers fit this pattern already, or nearly do.

We remove new_json_result() in favor of explicit json_stream_success()
and json_stream_fail(), but still allowing command_fail() if you just
want a simple all-in-one fail wrapper.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-10-19 11:47:48 +10:30
parent 12adcda370
commit e46ce0fc84
21 changed files with 224 additions and 195 deletions

View File

@@ -65,7 +65,7 @@ static struct connect *find_connect(struct lightningd *ld,
static void connect_cmd_succeed(struct command *cmd, const struct pubkey *id)
{
struct json_result *response = new_json_result(cmd);
struct json_result *response = json_stream_success(cmd);
json_object_start(response, NULL);
json_add_pubkey(response, "id", id);
json_object_end(response);