From 35b44d52941d850b4654e6507d4ffe540d4706c4 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 2 Feb 2018 19:47:30 +0100 Subject: [PATCH] gossip: Remember which broadcast index the node_announcement had Avoids searching for it in the uintmap. Signed-off-by: Christian Decker --- gossipd/routing.c | 10 ++++++---- gossipd/routing.h | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 3ca3e7556..713015829 100644 --- a/gossipd/routing.c +++ b/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->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); diff --git a/gossipd/routing.h b/gossipd/routing.h index f2fb72cb4..2b032c655 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -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);