From 8e571ba6882afc9cdc3b880d2d6cff6e0cbd3dee Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jun 2018 09:24:57 +0930 Subject: [PATCH] listnodes: expose global features. Since nobody sets these yet, it's a bit moot, but it will be great in future. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 7 +++---- gossipd/routing.c | 3 +++ gossipd/routing.h | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index f983a82e6..00f32556d 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -2146,15 +2146,14 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon, for (size_t i = 0; i < tal_count(ids); i++) { n = get_node(daemon->rstate, &ids[i]); if (n) - /* FIXME: Keep global features from node_announcement! */ - append_node(&nodes, &ids[i], NULL, NULL, n); + append_node(&nodes, &ids[i], n->gfeatures, + NULL, n); } } else { struct node_map_iter i; n = node_map_first(daemon->rstate->nodes, &i); while (n != NULL) { - /* FIXME: Keep global features from node_announcement! */ - append_node(&nodes, &n->id, NULL, NULL, n); + append_node(&nodes, &n->id, n->gfeatures, NULL, n); n = node_map_next(daemon->rstate->nodes, &i); } } diff --git a/gossipd/routing.c b/gossipd/routing.c index 2dcf2c22d..0a4b74d40 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -148,6 +148,7 @@ static struct node *new_node(struct routing_state *rstate, n->id = *id; n->chans = tal_arr(n, struct chan *, 0); n->alias = NULL; + n->gfeatures = NULL; n->node_announcement = NULL; n->node_announcement_index = 0; n->last_timestamp = -1; @@ -1287,6 +1288,8 @@ bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg T memcpy(node->rgb_color, rgb_color, 3); tal_free(node->alias); node->alias = tal_dup_arr(node, u8, alias, 32, 0); + tal_free(node->gfeatures); + node->gfeatures = tal_steal(node, features); tal_free(node->node_announcement); node->node_announcement = tal_dup_arr(node, u8, msg, tal_len(msg), 0); diff --git a/gossipd/routing.h b/gossipd/routing.h index 2c95df826..d2fd42d48 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -101,6 +101,9 @@ struct node { /* Color to be used when displaying the name */ u8 rgb_color[3]; + /* (Global) features */ + u8 *gfeatures; + /* Cached `node_announcement` we might forward to new peers (or NULL). */ const u8 *node_announcement; /* If public, this is non-zero. */