common: move json_stream from lightningd/ to common/

It's not lightningd-specific and we are going to need it for libplugin. The only
drawback is the log_io removal in json_stream_output_write()..
This commit is contained in:
darosior 2020-01-20 10:23:55 +01:00 committed by Rusty Russell
parent 9030e5d779
commit d35387f489
9 changed files with 11 additions and 14 deletions

View file

@ -34,6 +34,7 @@ COMMON_SRC_NOGEN := \
common/io_lock.c \
common/json.c \
common/json_helpers.c \
common/json_stream.c \
common/json_tok.c \
common/key_derive.c \
common/keyset.c \

View file

@ -6,10 +6,8 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/daemon.h>
#include <common/json_stream.h>
#include <common/utils.h>
#include <lightningd/json.h>
#include <lightningd/json_stream.h>
#include <lightningd/log.h>
#include <stdarg.h>
#include <stdio.h>
@ -208,8 +206,6 @@ static struct io_plan *json_stream_output_write(struct io_conn *conn,
}
js->reader = conn;
if (js->log)
log_io(js->log, LOG_IO_OUT, NULL, "", p, js->len_read);
return io_write(conn,
p, js->len_read,
json_stream_output_write, js);

View file

@ -1,8 +1,8 @@
/* lightningd/json_stream.h
* Helpers for outputting JSON results into a membuf.
*/
#ifndef LIGHTNING_LIGHTNINGD_JSON_STREAM_H
#define LIGHTNING_LIGHTNINGD_JSON_STREAM_H
#ifndef LIGHTNING_COMMON_JSON_STREAM_H
#define LIGHTNING_COMMON_JSON_STREAM_H
#include "config.h"
#include <ccan/membuf/membuf.h>
#include <ccan/short_types/short_types.h>
@ -131,4 +131,4 @@ struct io_plan *json_stream_output_(struct json_stream *js,
void json_stream_flush(struct json_stream *js);
#endif /* LIGHTNING_LIGHTNINGD_JSON_STREAM_H */
#endif /* LIGHTNING_COMMON_JSON_STREAM_H */

View file

@ -42,6 +42,7 @@ LIGHTNINGD_COMMON_OBJS := \
common/io_lock.o \
common/json.o \
common/json_helpers.o \
common/json_stream.o \
common/json_tok.o \
common/memleak.o \
common/msg_queue.o \
@ -81,7 +82,6 @@ LIGHTNINGD_SRC := \
lightningd/invoice.c \
lightningd/io_loop_with_timers.c \
lightningd/json.c \
lightningd/json_stream.c \
lightningd/jsonrpc.c \
lightningd/lightningd.c \
lightningd/log.c \

View file

@ -6,6 +6,7 @@
#include <common/features.h>
#include <common/json_command.h>
#include <common/json_helpers.h>
#include <common/json_stream.h>
#include <common/jsonrpc_errors.h>
#include <common/memleak.h>
#include <common/node_id.h>
@ -21,7 +22,6 @@
#include <lightningd/connect_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/json.h>
#include <lightningd/json_stream.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
#include <lightningd/log.h>

View file

@ -10,6 +10,7 @@
#include <common/json.h>
#include <common/json_command.h>
#include <common/json_helpers.h>
#include <common/json_stream.h>
#include <common/jsonrpc_errors.h>
#include <common/memleak.h>
#include <common/node_id.h>
@ -21,7 +22,6 @@
#include <gossipd/routing.h>
#include <lightningd/chaintopology.h>
#include <lightningd/json.h>
#include <lightningd/json_stream.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/options.h>
#include <sys/socket.h>

View file

@ -6,7 +6,7 @@
#include <ccan/list/list.h>
#include <common/errcode.h>
#include <common/json.h>
#include <lightningd/json_stream.h>
#include <common/json_stream.h>
#include <stdarg.h>
struct jsonrpc;

View file

@ -5,7 +5,7 @@
#include <ccan/autodata/autodata.h>
#include <ccan/tal/tal.h>
#include <ccan/typesafe_cb/typesafe_cb.h>
#include <lightningd/json_stream.h>
#include <common/json_stream.h>
#include <lightningd/lightningd.h>
#include <lightningd/plugin.h>

View file

@ -1,4 +1,4 @@
#include "../json_stream.c"
#include "../../common/json_stream.c"
#include "../jsonrpc.c"
#include "../json.c"