mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 15:04:19 +01:00
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>
This commit is contained in:
committed by
Christian Decker
parent
5970890fae
commit
a073c201e0
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user