diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index b60e1fc22..49ae1e968 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -174,7 +174,7 @@ static bool add_local_unnannounced(int fd, const u8 *msg; /* Ignore already announced. */ - if (c->channel_announce) + if (is_chan_public(c)) continue; msg = towire_gossipd_local_add_channel(tmpctx, &c->scid, diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index e76c6c4d1..e4b2aa33d 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1112,7 +1112,7 @@ static void maybe_create_next_scid_reply(struct peer *peer) if (!chan || !is_chan_public(chan)) continue; - queue_peer_msg(peer, chan->channel_announce); + queue_peer_from_store(peer, &chan->bcast); if (chan->half[0].channel_update) queue_peer_msg(peer, chan->half[0].channel_update); if (chan->half[1].channel_update) diff --git a/gossipd/routing.c b/gossipd/routing.c index c250a75ec..90c7b3d00 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -424,7 +424,6 @@ struct chan *new_chan(struct routing_state *rstate, chan->nodes[n1idx] = n1; chan->nodes[!n1idx] = n2; chan->txout_script = NULL; - chan->channel_announce = NULL; broadcastable_init(&chan->bcast); chan->sat = satoshis; chan->local_disabled = false; @@ -917,14 +916,14 @@ static bool is_local_channel(const struct routing_state *rstate, static void add_channel_announce_to_broadcast(struct routing_state *rstate, struct chan *chan, + const u8 *channel_announce, u32 timestamp, u32 index) { chan->bcast.timestamp = timestamp; /* 0, unless we're loading from store */ chan->bcast.index = index; - insert_broadcast(&rstate->broadcasts, chan->channel_announce, - &chan->bcast); + insert_broadcast(&rstate->broadcasts, channel_announce, &chan->bcast); rstate->local_channel_announced |= is_local_channel(rstate, chan); } @@ -950,6 +949,9 @@ bool routing_add_channel_announcement(struct routing_state *rstate, if (taken(msg)) tal_steal(tmpctx, msg); + if (taken(msg)) + tal_steal(tmpctx, msg); + if (!fromwire_channel_announcement( tmpctx, msg, &node_signature_1, &node_signature_2, &bitcoin_signature_1, &bitcoin_signature_2, &features, &chain_hash, @@ -1427,15 +1429,17 @@ bool routing_add_channel_update(struct routing_state *rstate, * receiving the first corresponding `channel_update`. */ if (uc) { - chan->channel_announce = tal_steal(chan, uc->channel_announce); - add_channel_announce_to_broadcast(rstate, chan, timestamp, + add_channel_announce_to_broadcast(rstate, chan, + uc->channel_announce, + timestamp, uc->index); - } else if (!chan->channel_announce) { + } else if (!is_chan_public(chan)) { /* For private channels, we get updates without an announce: don't * broadcast them! But save local ones to store anyway. */ struct half_chan *hc = &chan->half[direction]; /* Don't save if we're loading from store */ - if (is_local_channel(rstate, chan) && !index) { + assert(is_local_channel(rstate, chan)); + if (!index) { hc->bcast.index = gossip_store_add(rstate->broadcasts->gs, hc->channel_update); } else diff --git a/gossipd/routing.h b/gossipd/routing.h index 77ec07094..da0987bc9 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -52,9 +52,6 @@ struct chan { /* node[0].id < node[1].id */ struct node *nodes[2]; - /* NULL if not announced yet (ie. not public). */ - const u8 *channel_announce; - /* Timestamp and index into store file */ struct broadcastable bcast;