json_stream: disentangle JSON handling from command.

We promote 'struct json_stream' to contain the membuf; we only attach
the json_stream to the command when we actually call
json_stream_success / json_stream_fail.

This means we are closer to 'struct json_stream' being an independent
layer; the tests are already modified to use it directly to create
JSON.

This is also the first step toward re-enabling non-serial command
execution.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-11-20 12:16:32 +10:30
committed by Christian Decker
parent db3f0ba965
commit e17f69ce2d
12 changed files with 499 additions and 356 deletions

View File

@@ -1,5 +1,7 @@
#include "config.h"
#include "../json.c"
#include "../json_escaped.c"
#include "../json_stream.c"
#include "../param.c"
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
@@ -40,12 +42,6 @@ const char *feerate_name(enum feerate feerate UNNEEDED)
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for jcon_append */
void jcon_append(struct json_connection *jcon UNNEEDED, const char *str UNNEEDED)
{ fprintf(stderr, "jcon_append called!\n"); abort(); }
/* Generated stub for jcon_append_vfmt */
void jcon_append_vfmt(struct json_connection *jcon UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "jcon_append_vfmt called!\n"); abort(); }
/* Generated stub for json_feerate_estimate */
bool json_feerate_estimate(struct command *cmd UNNEEDED,
u32 **feerate_per_kw UNNEEDED, enum feerate feerate UNNEEDED)