From 2fd4a0121ff0cac84d6412676dae959f8fff1b81 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 11 Apr 2019 14:45:22 +0930 Subject: [PATCH] gossipd: unify is_chan_public / is_chan_announced. We used to have a `struct chan` while we're waiting for an update; now we keep that internally. So a `struct chan` without a channel_announcement in the store is private, and other is public. Signed-off-by: Rusty Russell --- gossipd/gossipd.c | 2 +- gossipd/routing.c | 2 +- gossipd/routing.h | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index d0de40038..e76c6c4d1 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -1109,7 +1109,7 @@ static void maybe_create_next_scid_reply(struct peer *peer) struct chan *chan; chan = get_channel(rstate, &peer->scid_queries[i]); - if (!chan || !is_chan_announced(chan)) + if (!chan || !is_chan_public(chan)) continue; queue_peer_msg(peer, chan->channel_announce); diff --git a/gossipd/routing.c b/gossipd/routing.c index 1c35ae618..c250a75ec 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -307,7 +307,7 @@ static bool node_announce_predates_channels(const struct node *node) struct chan *c; for (c = first_chan(node, &i); c; c = next_chan(node, &i)) { - if (!is_chan_announced(c)) + if (!is_chan_public(c)) continue; if (c->bcast.index < node->bcast.index) diff --git a/gossipd/routing.h b/gossipd/routing.h index aa84a3527..77ec07094 100644 --- a/gossipd/routing.h +++ b/gossipd/routing.h @@ -64,15 +64,9 @@ struct chan { struct amount_sat sat; }; -/* A local channel can exist which isn't announcable. */ +/* A local channel can exist which isn't announced; normal channels are only + * created once we have both an announcement *and* an update. */ static inline bool is_chan_public(const struct chan *chan) -{ - return chan->channel_announce != NULL; -} - -/* A channel is only announced once we have a channel_update to send - * with it. */ -static inline bool is_chan_announced(const struct chan *chan) { return chan->bcast.index != 0; }