From b7ec2c8c9c6c58ee3ef3e0c5cbf390255bb0527f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 2 Mar 2018 19:29:17 +1030 Subject: [PATCH] node_connection: move channel_announcement field into struct routing_channel. We don't actually *use it*, mind you: the copy in the broadcast message is the one we use. Signed-off-by: Rusty Russell --- gossipd/routing.c | 12 +++--------- gossipd/routing.h | 7 ++++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 1ddd03694..79bf14f87 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -238,7 +238,6 @@ static struct node_connection *new_node_connection(struct routing_state *rstate, c->src = from; c->dst = to; c->short_channel_id = chan->scid; - c->channel_announcement = NULL; c->channel_update = NULL; c->unroutable_until = 0; c->active = false; @@ -274,6 +273,7 @@ struct routing_channel *new_routing_channel(struct routing_state *rstate, chan->nodes[n1idx] = n1; chan->nodes[!n1idx] = n2; chan->txout_script = NULL; + chan->channel_announcement = NULL; chan->public = false; memset(&chan->msg_indexes, 0, sizeof(chan->msg_indexes)); @@ -776,14 +776,8 @@ bool handle_pending_cannouncement(struct routing_state *rstate, chan->public = true; /* Save channel_announcement. */ - tal_free(chan->connections[0]->channel_announcement); - chan->connections[0]->channel_announcement - = tal_dup_arr(chan->connections[0], u8, pending->announce, - tal_len(pending->announce), 0); - tal_free(chan->connections[1]->channel_announcement); - chan->connections[1]->channel_announcement - = tal_dup_arr(chan->connections[1], u8, pending->announce, - tal_len(pending->announce), 0); + tal_free(chan->channel_announcement); + chan->channel_announcement = tal_steal(chan, pending->announce); if (replace_broadcast(rstate->broadcasts, &chan->msg_indexes[MSG_INDEX_CANNOUNCE], diff --git a/gossipd/routing.h b/gossipd/routing.h index a1c99b68f..7ba222292 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -39,9 +39,7 @@ struct node_connection { * things indicated direction wrt the `channel_id` */ u16 flags; - /* Cached `channel_announcement` and `channel_update` we might forward to new peers*/ - /* FIXME: Remove */ - u8 *channel_announcement; + /* Cached `channel_update` we might forward to new peers*/ u8 *channel_update; /* If greater than current time, this connection should not @@ -104,6 +102,9 @@ struct routing_channel { /* nodes[0].id < nodes[1].id */ struct node *nodes[2]; + /* Cached `channel_announcement` we might forward to new peers*/ + const u8 *channel_announcement; + /* FIXME: Move msg_index[MSG_INDEX_CUPDATE*] into connections[] */ u64 msg_indexes[3];