Browse Source

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 <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
a073c201e0
  1. 6
      gossipd/gossip.c
  2. 3
      gossipd/routing.c
  3. 3
      gossipd/routing.h

6
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 */

3
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);
}

3
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,

Loading…
Cancel
Save