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>
This commit is contained in:
Christian Decker 2018-02-02 19:47:30 +01:00 committed by Rusty Russell
parent 24d52ec23a
commit 35b44d5294
2 changed files with 9 additions and 4 deletions

View file

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

View file

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