Browse Source

gossip: Remember which broadcast index the node_announcement had

Avoids searching for it in the uintmap.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
35b44d5294
  1. 10
      gossipd/routing.c
  2. 3
      gossipd/routing.h

10
gossipd/routing.c

@ -130,6 +130,7 @@ static struct node *new_node(struct routing_state *rstate,
n->out = tal_arr(n, struct node_connection *, 0); n->out = tal_arr(n, struct node_connection *, 0);
n->alias = NULL; n->alias = NULL;
n->node_announcement = NULL; n->node_announcement = NULL;
n->announcement_idx = 0;
n->last_timestamp = -1; n->last_timestamp = -1;
n->addresses = tal_arr(n, struct wireaddr, 0); n->addresses = tal_arr(n, struct wireaddr, 0);
node_map_add(rstate->nodes, n); node_map_add(rstate->nodes, n);
@ -1038,10 +1039,11 @@ void handle_node_announcement(
u8 *tag = tal_arr(tmpctx, u8, 0); u8 *tag = tal_arr(tmpctx, u8, 0);
towire_pubkey(&tag, &node_id); towire_pubkey(&tag, &node_id);
queue_broadcast(rstate->broadcasts, replace_broadcast(rstate->broadcasts,
WIRE_NODE_ANNOUNCEMENT, &node->announcement_idx,
tag, WIRE_NODE_ANNOUNCEMENT,
serialized); tag,
serialized);
tal_free(node->node_announcement); tal_free(node->node_announcement);
node->node_announcement = tal_steal(node, serialized); node->node_announcement = tal_steal(node, serialized);
tal_free(tmpctx); tal_free(tmpctx);

3
gossipd/routing.h

@ -74,6 +74,9 @@ struct node {
/* Cached `node_announcement` we might forward to new peers. */ /* Cached `node_announcement` we might forward to new peers. */
u8 *node_announcement; u8 *node_announcement;
/* What index does the announcement broadcast have? */
u64 announcement_idx;
}; };
const secp256k1_pubkey *node_map_keyof_node(const struct node *n); const secp256k1_pubkey *node_map_keyof_node(const struct node *n);

Loading…
Cancel
Save