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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-03-26 09:22:11 +10:30 committed by Christian Decker
parent 0ff33c874a
commit baf091bae6

View file

@ -239,6 +239,16 @@ static void normal_gossip_start(struct seeker *seeker, struct peer *peer)
{
bool enable_stream = false;
/* BOLT-remove-old-features #7:
* Understanding of messages used to be indicated with the `gossip_queries`
* feature bit; now these messages are universally supported, that feature has
* now been slightly repurposed. Not offering this feature means a node is not
* worth querying for gossip: either they do not store the entire gossip map, or
* they are only connected to a single peer (this one).
*/
if (!peer->gossip_queries_feature)
return;
/* Make this one of our streaming gossipers if we aren't full */
for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) {
if (seeker->gossiper[i] == NULL) {
@ -850,6 +860,13 @@ static bool peer_is_not_gossipper(const struct peer *peer)
{
const struct seeker *seeker = peer->daemon->seeker;
/* BOLT-remove-old-features #7:
* `gossip_queries`... Not offering this feature means a node is not
* worth querying for gossip
*/
if (!peer->gossip_queries_feature)
return false;
for (size_t i = 0; i < ARRAY_SIZE(seeker->gossiper); i++) {
if (seeker->gossiper[i] == peer)
return false;
@ -864,7 +881,7 @@ static void maybe_rotate_gossipers(struct seeker *seeker)
struct peer *peer;
size_t i;
/* If all peers are gossiping, we're done */
/* If all (usable) peers are gossiping, we're done */
peer = random_seeker(seeker, peer_is_not_gossipper);
if (!peer)
return;