From 997e3f7fe6dc2c7c1757baf8ea29e6feae3adb0e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 14 Nov 2019 10:47:53 +1030 Subject: [PATCH] lightningd: move json_add_route into gossip_control.c and make static. There's only one caller. Signed-off-by: Rusty Russell --- lightningd/gossip_control.c | 27 +++++++++++++++++++++++++++ lightningd/json.c | 29 ----------------------------- lightningd/json.h | 5 ----- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 927549d0b..677f007cd 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -303,6 +303,33 @@ static const struct json_command listnodes_command = { }; AUTODATA(json_command, &listnodes_command); +/* Output a route hop */ +static void json_add_route_hop(struct json_stream *r, char const *n, + const struct route_hop *h) +{ + /* Imitate what getroute/sendpay use */ + json_object_start(r, n); + json_add_node_id(r, "id", &h->nodeid); + json_add_short_channel_id(r, "channel", + &h->channel_id); + json_add_num(r, "direction", h->direction); + json_add_amount_msat_compat(r, h->amount, "msatoshi", "amount_msat"); + json_add_num(r, "delay", h->delay); + json_object_end(r); +} + +/* Output a route */ +static void json_add_route(struct json_stream *r, char const *n, + const struct route_hop *hops, size_t hops_len) +{ + size_t i; + json_array_start(r, n); + for (i = 0; i < hops_len; ++i) { + json_add_route_hop(r, NULL, &hops[i]); + } + json_array_end(r); +} + static void json_getroute_reply(struct subd *gossip UNUSED, const u8 *reply, const int *fds UNUSED, struct command *cmd) { diff --git a/lightningd/json.c b/lightningd/json.c index fdbbd0437..8de71cdbf 100644 --- a/lightningd/json.c +++ b/lightningd/json.c @@ -27,35 +27,6 @@ #include #include -/* Output a route hop */ -static void -json_add_route_hop(struct json_stream *r, char const *n, - const struct route_hop *h) -{ - /* Imitate what getroute/sendpay use */ - json_object_start(r, n); - json_add_node_id(r, "id", &h->nodeid); - json_add_short_channel_id(r, "channel", - &h->channel_id); - json_add_num(r, "direction", h->direction); - json_add_amount_msat_compat(r, h->amount, "msatoshi", "amount_msat"); - json_add_num(r, "delay", h->delay); - json_object_end(r); -} - -/* Output a route */ -void -json_add_route(struct json_stream *r, char const *n, - const struct route_hop *hops, size_t hops_len) -{ - size_t i; - json_array_start(r, n); - for (i = 0; i < hops_len; ++i) { - json_add_route_hop(r, NULL, &hops[i]); - } - json_array_end(r); -} - void json_add_node_id(struct json_stream *response, const char *fieldname, const struct node_id *id) diff --git a/lightningd/json.h b/lightningd/json.h index 165b821ef..a47fe8e44 100644 --- a/lightningd/json.h +++ b/lightningd/json.h @@ -26,7 +26,6 @@ struct json_escape; struct json_stream; struct pubkey; struct node_id; -struct route_hop; struct sha256; struct short_channel_id; struct wallet_payment; @@ -34,10 +33,6 @@ struct wallet_tx; struct wireaddr; struct wireaddr_internal; -/* Output a route array. */ -void json_add_route(struct json_stream *r, char const *n, - const struct route_hop *hops, size_t hops_len); - /* '"fieldname" : "0289abcdef..."' or "0289abcdef..." if fieldname is NULL */ void json_add_pubkey(struct json_stream *response, const char *fieldname,