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

Function check_firstpeer

gossipd/seeker.c:742–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742static void check_firstpeer(struct seeker *seeker)
743{
744 struct peer *peer = seeker->random_peer_softref, *p;
745
746 /* It might have died, pick another. */
747 if (!peer) {
748 peer = random_seeker(seeker, peer_has_gossip_queries);
749 /* No peer? Wait for a new one to join. */
750 if (!peer) {
751 status_debug("seeker: no peers, waiting");
752 return;
753 }
754
755 peer_gossip_startup(seeker, peer);
756 return;
757 }
758
759 /* If no progress, we assume it's finished, and if it hasn't,
760 * we'll end up querying backwards in next steps. */
761 if (peer_made_progress(seeker))
762 return;
763
764 /* Other peers can gossip now. */
765 status_peer_debug(&peer->id, "seeker: startup peer finished");
766 clear_softref(seeker, &seeker->random_peer_softref);
767 list_for_each(&seeker->daemon->peers, p, list) {
768 if (p == peer)
769 continue;
770
771 normal_gossip_start(seeker, p);
772 }
773
774 /* Ask a random peer for all channels, in case we're missing */
775 seeker->scid_probe_start = chainparams->when_lightning_became_cool;
776 seeker->scid_probe_end = seeker->daemon->current_blockheight;
777 if (seeker->scid_probe_start > seeker->scid_probe_end)
778 seeker->scid_probe_start = 0;
779 peer_gossip_probe_scids(seeker);
780}
781
782static void check_probe(struct seeker *seeker,
783 void (*restart)(struct seeker *seeker))

Callers 1

seeker_checkFunction · 0.85

Calls 5

random_seekerFunction · 0.85
peer_gossip_startupFunction · 0.85
peer_made_progressFunction · 0.85
normal_gossip_startFunction · 0.85
peer_gossip_probe_scidsFunction · 0.85

Tested by

no test coverage detected