Browse Source

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()..
travis-debug
darosior 5 years ago
committed by Rusty Russell
parent
commit
d35387f489
  1. 1
      common/Makefile
  2. 6
      common/json_stream.c
  3. 6
      common/json_stream.h
  4. 2
      lightningd/Makefile
  5. 2
      lightningd/connect_control.c
  6. 2
      lightningd/json.c
  7. 2
      lightningd/jsonrpc.h
  8. 2
      lightningd/plugin_hook.h
  9. 2
      lightningd/test/run-jsonrpc.c

1
common/Makefile

@ -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 \

6
lightningd/json_stream.c → common/json_stream.c

@ -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);

6
lightningd/json_stream.h → common/json_stream.h

@ -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 */

2
lightningd/Makefile

@ -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 \

2
lightningd/connect_control.c

@ -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>

2
lightningd/json.c

@ -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>

2
lightningd/jsonrpc.h

@ -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;

2
lightningd/plugin_hook.h

@ -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>

2
lightningd/test/run-jsonrpc.c

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

Loading…
Cancel
Save