mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 23:04:35 +01:00
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:
@@ -718,7 +718,7 @@ bool json_tok_loglevel(struct command *cmd, const char *name,
|
||||
static void json_getlog(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t * params)
|
||||
{
|
||||
struct json_result *response = new_json_result(cmd);
|
||||
struct json_result *response;
|
||||
enum log_level *minlevel;
|
||||
struct log_book *lr = cmd->ld->log_book;
|
||||
|
||||
@@ -728,6 +728,7 @@ static void json_getlog(struct command *cmd,
|
||||
NULL))
|
||||
return;
|
||||
|
||||
response = json_stream_success(cmd);
|
||||
json_object_start(response, NULL);
|
||||
json_add_time(response, "created_at", log_init_time(lr)->ts);
|
||||
json_add_num(response, "bytes_used", (unsigned int) log_used(lr));
|
||||
|
||||
Reference in New Issue
Block a user