Skip to content

Commit 06e850c

Browse files
committed
gossipd: be stricter with non-gossip_query nodes.
We now *never* consider asking them anything, even if they are capable (e.g. enabling full gossip stream). This aligns with the latest spec proposal, where lack of `gossip_queries` means "we don't have anything useful to say". Signed-off-by: Rusty Russell <[email protected]>
1 parent f7eacb7 commit 06e850c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

gossipd/seeker.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ static void normal_gossip_start(struct seeker *seeker, struct peer *peer)
239239
{
240240
bool enable_stream = false;
241241

242+
/* BOLT-remove-old-features #7:
243+
* Understanding of messages used to be indicated with the `gossip_queries`
244+
* feature bit; now these messages are universally supported, that feature has
245+
* now been slightly repurposed. Not offering this feature means a node is not
246+
* worth querying for gossip: either they do not store the entire gossip map, or
247+
* they are only connected to a single peer (this one).
248+
*/
249+
if (!peer->gossip_queries_feature)
250+
return;
251+
242252
/* Make this one of our streaming gossipers if we aren't full */
243253
for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) {
244254
if (seeker->gossiper[i] == NULL) {
@@ -850,6 +860,13 @@ static bool peer_is_not_gossipper(const struct peer *peer)
850860
{
851861
const struct seeker *seeker = peer->daemon->seeker;
852862

863+
/* BOLT-remove-old-features #7:
864+
* `gossip_queries`... Not offering this feature means a node is not
865+
* worth querying for gossip
866+
*/
867+
if (!peer->gossip_queries_feature)
868+
return false;
869+
853870
for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) {
854871
if (seeker->gossiper[i] == peer)
855872
return false;
@@ -864,7 +881,7 @@ static void maybe_rotate_gossipers(struct seeker *seeker)
864881
struct peer *peer;
865882
size_t i;
866883

867-
/* If all peers are gossiping, we're done */
884+
/* If all (usable) peers are gossiping, we're done */
868885
peer = random_seeker(seeker, peer_is_not_gossipper);
869886
if (!peer)
870887
return;

0 commit comments

Comments
 (0)