common/json_stream: support filtering don't print fields not allowed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-11-09 14:10:54 +10:30
parent 22c42de6f1
commit f0731d2ca1
7 changed files with 88 additions and 19 deletions

View File

@@ -13,6 +13,7 @@
#include <ccan/time/time.h>
#include <common/amount.h>
#include <common/jsonrpc_errors.h>
#include <common/utils.h>
struct command;
struct io_conn;
@@ -48,6 +49,9 @@ struct json_stream {
void *reader_arg;
size_t len_read;
/* If non-NULL, reflects the current filter position */
struct json_filter *filter;
/* Where to log I/O */
struct log *log;
};
@@ -78,6 +82,14 @@ struct json_stream *json_stream_dup(const tal_t *ctx,
struct json_stream *original,
struct log *log);
/* Attach a filter. Usually this works at the result level: you don't
* want to filter out id, etc! */
void json_stream_attach_filter(struct json_stream *js,
struct json_filter *filter STEALS);
/* Detach the filter: returns non-NULL string if it was misused. */
const char *json_stream_detach_filter(const tal_t *ctx, struct json_stream *js);
/**
* json_stream_close - finished writing to a JSON stream.
* @js: the json_stream.