From 95bc8f69873ceb8c8a274b0fd985b7fe6026f8e7 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 21 Dec 2016 17:07:06 +0100 Subject: [PATCH] gossip: Removing origin from staggered broadcast Keeping a pointer to the peer that initially sent us a message could (actually will!) result in dangling pointers. Removing this results in some additional messages, which will be discarded by the recipient, so that should not be a problem. --- daemon/p2p_announce.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/daemon/p2p_announce.c b/daemon/p2p_announce.c index 08e5bb0e4..2e90b792a 100644 --- a/daemon/p2p_announce.c +++ b/daemon/p2p_announce.c @@ -26,9 +26,6 @@ struct queued_message { u8 *payload; struct list_node list; - - /* who told us about this message? */ - struct peer *origin; }; u8 ipv4prefix[] = { @@ -81,8 +78,7 @@ static void queue_broadcast(struct lightningd_state *dstate, const int type, const u32 timestamp, const u8 *tag, - const u8 *payload, - struct peer *origin) + const u8 *payload) { struct queued_message *el, *msg; list_for_each(&dstate->broadcast_queue, el, list) { @@ -94,7 +90,6 @@ static void queue_broadcast(struct lightningd_state *dstate, el->payload = tal_free(el->payload); el->payload = tal_dup_arr(el, u8, payload, tal_count(payload), 0); el->timestamp = timestamp; - el->origin = origin; return; } } @@ -105,7 +100,6 @@ static void queue_broadcast(struct lightningd_state *dstate, msg->timestamp = timestamp; msg->tag = tal_dup_arr(msg, u8, tag, tal_count(tag), 0); msg->payload = tal_dup_arr(msg, u8, payload, tal_count(payload), 0); - msg->origin = origin; list_add_tail(&dstate->broadcast_queue, &msg->list); } @@ -172,7 +166,7 @@ void handle_channel_announcement( towire_channel_id(&tag, &msg->channel_id); queue_broadcast(peer->dstate, WIRE_CHANNEL_ANNOUNCEMENT, 0, /* `channel_announcement`s do not have a timestamp */ - tag, serialized, peer); + tag, serialized); tal_free(msg); } @@ -228,7 +222,7 @@ void handle_channel_update(struct peer *peer, const struct msg_channel_update *m WIRE_CHANNEL_UPDATE, msg->timestamp, tag, - serialized, peer); + serialized); tal_free(c->channel_update); c->channel_update = tal_dup_arr(c, u8, serialized, tal_count(serialized), 0); @@ -281,7 +275,7 @@ void handle_node_announcement( WIRE_NODE_ANNOUNCEMENT, msg->timestamp, tag, - serialized, peer); + serialized); tal_free(node->node_announcement); node->node_announcement = tal_dup_arr(node, u8, serialized, tal_count(serialized), 0); tal_free(msg);