gossipd: use optional fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-07-09 20:47:49 +09:30 committed by Christian Decker
parent ac4c6b1a82
commit 019ba86b91
2 changed files with 11 additions and 22 deletions

View File

@ -2269,18 +2269,15 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon,
u8 *out;
struct node *n;
const struct gossip_getnodes_entry **nodes;
struct pubkey *ids;
struct pubkey *id;
fromwire_gossip_getnodes_request(tmpctx, msg, &ids);
fromwire_gossip_getnodes_request(tmpctx, msg, &id);
nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, 0);
if (ids) {
for (size_t i = 0; i < tal_count(ids); i++) {
n = get_node(daemon->rstate, &ids[i]);
if (n)
append_node(&nodes, &ids[i], n->gfeatures,
NULL, n);
}
if (id) {
n = get_node(daemon->rstate, id);
if (n)
append_node(&nodes, id, n->gfeatures, NULL, n);
} else {
struct node_map_iter i;
n = node_map_first(daemon->rstate->nodes, &i);
@ -3556,7 +3553,7 @@ static struct io_plan *get_peers(struct io_conn *conn,
struct pubkey *id = tal_arr(conn, struct pubkey, n);
struct wireaddr_internal *wireaddr = tal_arr(conn, struct wireaddr_internal, n);
const struct gossip_getnodes_entry **nodes = tal_arr(conn, const struct gossip_getnodes_entry *, n);
struct pubkey *specific_id = NULL;
struct pubkey *specific_id;
if (!fromwire_gossip_getpeers_request(msg, msg, &specific_id))
master_badmsg(WIRE_GOSSIPCTL_PEER_ADDRHINT, msg);

View File

@ -18,9 +18,7 @@ gossipctl_init,,rgb,3*u8
gossipctl_init,,alias,32*u8
gossipctl_init,,update_channel_interval,u32
gossipctl_init,,reconnect,bool
# This is 0 or 1.
gossipctl_init,,num_tor_proxyaddrs,u16
gossipctl_init,,tor_proxyaddr,num_tor_proxyaddrs*struct wireaddr
gossipctl_init,,tor_proxyaddr,?struct wireaddr
gossipctl_init,,use_tor_proxy_always,bool
gossipctl_init,,dev_allow_localhost,bool
gossipctl_init,,use_dns,bool
@ -112,9 +110,7 @@ gossipctl_peer_disconnected,,id,struct pubkey
# Pass JSON-RPC getnodes call through
gossip_getnodes_request,3005
# Can be 0 or 1 currently
gossip_getnodes_request,,num,u16
gossip_getnodes_request,,id,num*struct pubkey
gossip_getnodes_request,,id,?struct pubkey
#include <lightningd/gossip_msg.h>
gossip_getnodes_reply,3105
@ -136,9 +132,7 @@ gossip_getroute_reply,,num_hops,u16
gossip_getroute_reply,,hops,num_hops*struct route_hop
gossip_getchannels_request,3007
# In practice, 0 or 1.
gossip_getchannels_request,,num,u16
gossip_getchannels_request,,short_channel_id,num*struct short_channel_id
gossip_getchannels_request,,short_channel_id,?struct short_channel_id
gossip_getchannels_reply,3107
gossip_getchannels_reply,,num_channels,u16
@ -201,9 +195,7 @@ gossip_resolve_channel_reply,,keys,num_keys*struct pubkey
# The main daemon asks for peers
gossip_getpeers_request,3011
# 0 or 1
gossip_getpeers_request,,num,u16
gossip_getpeers_request,,id,num*struct pubkey
gossip_getpeers_request,,id,?struct pubkey
gossip_getpeers_reply,3111
gossip_getpeers_reply,,num,u16

1 #include <common/cryptomsg.h>
18 gossipctl_init,,update_channel_interval,u32
19 gossipctl_init,,reconnect,bool
20 # This is 0 or 1. gossipctl_init,,tor_proxyaddr,?struct wireaddr
21 gossipctl_init,,num_tor_proxyaddrs,u16 gossipctl_init,,use_tor_proxy_always,bool
gossipctl_init,,tor_proxyaddr,num_tor_proxyaddrs*struct wireaddr
gossipctl_init,,use_tor_proxy_always,bool
22 gossipctl_init,,dev_allow_localhost,bool
23 gossipctl_init,,use_dns,bool
24 gossipctl_init,,tor_password,wirestring
110 gossip_getroute_request,,riskfactor,u16 gossip_getroute_request,,fuzz,double
111 gossip_getroute_request,,final_cltv,u32 gossip_getroute_request,,seed,struct siphash_seed
112 gossip_getroute_request,,fuzz,double gossip_getroute_reply,3106
113 gossip_getroute_request,,seed,struct siphash_seed gossip_getroute_reply,,num_hops,u16
gossip_getroute_reply,3106
gossip_getroute_reply,,num_hops,u16
114 gossip_getroute_reply,,hops,num_hops*struct route_hop
115 gossip_getchannels_request,3007
116 # In practice, 0 or 1. gossip_getchannels_request,,short_channel_id,?struct short_channel_id
132 # Test of query_short_channel_ids. Master->gossipd gossip_query_scids,,id,struct pubkey
133 gossip_query_scids,3031 gossip_query_scids,,num_ids,u16
134 gossip_query_scids,,id,struct pubkey gossip_query_scids,,ids,num_ids*struct short_channel_id
135 gossip_query_scids,,num_ids,u16 # Gossipd -> master
gossip_query_scids,,ids,num_ids*struct short_channel_id
# Gossipd -> master
136 gossip_scids_reply,3131
137 gossip_scids_reply,,ok,bool
138 gossip_scids_reply,,complete,bool
195 gossip_local_channel_update,,disable,bool gossip_local_channel_update,,htlc_minimum_msat,u64
196 gossip_local_channel_update,,cltv_expiry_delta,u16 gossip_local_channel_update,,fee_base_msat,u32
197 gossip_local_channel_update,,htlc_minimum_msat,u64 gossip_local_channel_update,,fee_proportional_millionths,u32
198 gossip_local_channel_update,,fee_base_msat,u32 gossip_local_channel_close,3027
gossip_local_channel_update,,fee_proportional_millionths,u32
gossip_local_channel_close,3027
199 gossip_local_channel_close,,short_channel_id,struct short_channel_id
200 # Gossipd->master get this tx output please.
201 gossip_get_txout,3018