Browse Source

gossipd: use optional fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
019ba86b91
  1. 17
      gossipd/gossip.c
  2. 16
      gossipd/gossip_wire.csv

17
gossipd/gossip.c

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

16
gossipd/gossip_wire.csv

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

Can't render this file because it has a wrong number of fields in line 6.
Loading…
Cancel
Save