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

Function random_seeker

gossipd/seeker.c:159–175  ·  view source on GitHub ↗

Get a random peer, but try our preferred peer first, if any. This * biasses us to the peer that told us of unexpected gossip. */

Source from the content-addressed store, hash-verified

157/* Get a random peer, but try our preferred peer first, if any. This
158 * biasses us to the peer that told us of unexpected gossip. */
159static struct peer *random_seeker(struct seeker *seeker,
160 bool (*check_peer)(const struct peer *peer))
161{
162 struct peer *peer = seeker->preferred_peer_softref;
163
164 /* 80% chance of immediately choosing a peer who reported the missing
165 * stuff: they presumably can tell us more about it. We don't
166 * *always* choose it because it could be simply spamming us with
167 * invalid announcements to get chosen, and we don't handle that case
168 * well yet. */
169 if (peer && check_peer(peer) && pseudorand(5) != 0) {
170 clear_softref(seeker, &seeker->random_peer_softref);
171 return peer;
172 }
173
174 return random_peer(seeker->daemon, check_peer);
175}
176
177static bool peer_made_progress(struct seeker *seeker)
178{

Callers 7

seek_any_unknown_scidsFunction · 0.85
seek_any_stale_scidsFunction · 0.85
process_scid_probeFunction · 0.85
peer_gossip_probe_scidsFunction · 0.85
check_firstpeerFunction · 0.85
maybe_rotate_gossipersFunction · 0.85

Calls 2

random_peerFunction · 0.70
pseudorandFunction · 0.50

Tested by

no test coverage detected