From a073c201e0f62d6c631986500e568364ae36f004 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Feb 2018 06:46:43 +1030 Subject: [PATCH] gossip: expose and use get_node() helper. It's a trivial helper function from routing.c, but let's expose it and use it in gossip.c too. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 6 +++--- gossipd/routing.c | 3 +-- gossipd/routing.h | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index 2721c087b..92513f7dd 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -722,7 +722,7 @@ static void handle_get_update(struct peer *peer, const u8 *msg) } /* We want update than comes from our end. */ - us = node_map_get(peer->daemon->rstate->nodes, &peer->daemon->id.pubkey); + us = get_node(peer->daemon->rstate, &peer->daemon->id); if (!us) { status_trace("peer %s schanid %s but can't find ourselves", type_to_string(trc, struct pubkey, &peer->id), @@ -1149,7 +1149,7 @@ static struct io_plan *getnodes(struct io_conn *conn, struct daemon *daemon, nodes = tal_arr(tmpctx, const struct gossip_getnodes_entry *, 0); if (ids) { for (size_t i = 0; i < tal_count(ids); i++) { - n = node_map_get(daemon->rstate->nodes, &ids[i].pubkey); + n = get_node(daemon->rstate, &ids[i]); if (n) append_node(&nodes, n); } @@ -1311,7 +1311,7 @@ static void gossip_prune_network(struct daemon *daemon) gossip_prune_network, daemon); /* Find myself in the network */ - n = node_map_get(daemon->rstate->nodes, &daemon->id.pubkey); + n = get_node(daemon->rstate, &daemon->id); if (n) { /* Iterate through all outgoing connection and check whether * it's time to re-announce */ diff --git a/gossipd/routing.c b/gossipd/routing.c index f2fb92762..6b6a98631 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -134,8 +134,7 @@ static void destroy_node(struct node *node, struct routing_state *rstate) tal_free(node->out[0]); } -static struct node *get_node(struct routing_state *rstate, - const struct pubkey *id) +struct node *get_node(struct routing_state *rstate, const struct pubkey *id) { return node_map_get(rstate->nodes, &id->pubkey); } diff --git a/gossipd/routing.h b/gossipd/routing.h index cbb0f091e..50e5d17e6 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -175,6 +175,9 @@ bool handle_pending_cannouncement(struct routing_state *rstate, void handle_channel_update(struct routing_state *rstate, const u8 *update); void handle_node_announcement(struct routing_state *rstate, const u8 *node); +/* Get a node: use this instead of node_map_get() */ +struct node *get_node(struct routing_state *rstate, const struct pubkey *id); + /* Compute a route to a destination, for a given amount and riskfactor. */ struct route_hop *get_route(tal_t *ctx, struct routing_state *rstate, const struct pubkey *source,