Skip to content

Commit

Permalink
gossipd: unify is_chan_public / is_chan_announced.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell authored and niftynei committed Apr 12, 2019
1 parent aafc489 commit 2fd4a01
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gossipd/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions gossipd/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2fd4a01

Please sign in to comment.