mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
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:
parent
24d52ec23a
commit
35b44d5294
2 changed files with 9 additions and 4 deletions
|
@ -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);
|
||||||
|
|
|
@ -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…
Add table
Reference in a new issue