MCPcopy Create free account
hub / github.com/ElementsProject/lightning / nodeannounce_query_done

Function nodeannounce_query_done

gossipd/seeker.c:549–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547static void peer_gossip_probe_nannounces(struct seeker *seeker);
548
549static void nodeannounce_query_done(struct peer *peer, bool complete)
550{
551 struct daemon *daemon = peer->daemon;
552 struct seeker *seeker = daemon->seeker;
553 size_t new_nannounce = 0, num_scids;
554 struct gossmap *gossmap = gossmap_manage_get_gossmap(daemon->gm);
555
556 /* We might have given up on them, then they replied. */
557 if (seeker->random_peer != peer) {
558 status_peer_debug(&peer->id, "seeker: belated reply: ignoring");
559 return;
560 }
561
562 seeker->random_peer = NULL;
563
564 num_scids = tal_count(seeker->nannounce_scids);
565 for (size_t i = 0; i < num_scids; i++) {
566 struct gossmap_chan *c = gossmap_find_chan(gossmap,
567 &seeker->nannounce_scids[i]);
568 /* Could have closed since we asked. */
569 if (!c)
570 continue;
571 if ((seeker->nannounce_query_flags[i] & SCID_QF_NODE1)
572 && gossmap_node_announced(gossmap_nth_node(gossmap, c, 0)))
573 new_nannounce++;
574 if ((seeker->nannounce_query_flags[i] & SCID_QF_NODE2)
575 && gossmap_node_announced(gossmap_nth_node(gossmap, c, 1)))
576 new_nannounce++;
577 }
578
579 status_peer_debug(&peer->id,
580 "seeker: found %zu new node_announcements in %zu scids",
581 new_nannounce, num_scids);
582
583 seeker->nannounce_scids = tal_free(seeker->nannounce_scids);
584 seeker->nannounce_query_flags = tal_free(seeker->nannounce_query_flags);
585
586 if (!new_nannounce) {
587 set_state(seeker, NORMAL, NULL,
588 "No new node_announcements in %zu scids", num_scids);
589 return;
590 }
591
592 /* Since they told us about new announcements, keep asking them. */
593 set_preferred_peer(seeker, peer);
594
595 /* Double every time. We may skip a few, of course, since map
596 * is changing. */
597 num_scids *= 2;
598 /* Don't try to create a query larger than 64k */
599 if (num_scids > 7000)
600 num_scids = 7000;
601
602 if (!get_unannounced_nodes(seeker, seeker->daemon, num_scids,
603 &seeker->nannounce_scids,
604 &seeker->nannounce_query_flags)) {
605 /* Nothing unknown at all? Great, we're done */
606 set_state(seeker, NORMAL, NULL, "No unannounced nodes");

Callers

nothing calls this directly

Calls 8

gossmap_find_chanFunction · 0.85
gossmap_node_announcedFunction · 0.85
gossmap_nth_nodeFunction · 0.85
tal_freeFunction · 0.85
set_preferred_peerFunction · 0.85
get_unannounced_nodesFunction · 0.85

Tested by

no test coverage detected