INNER CODE UNIT · Go
findRelayPeers
kluctl/kluctl · internal/ipfs-exchange-info/main.go:140
func findRelayPeers(h func() host.Host) func(ctx context.Context, num int) <-chan peer.AddrInfo {
return func(ctx context.Context, num int) <-chan peer.AddrInfo {
ch := make(chan peer.AddrInfo)
go func() {
sent := 0
outer:
for {
for _, id := range h().Peerstore().PeersWithAddrs() {
if sent >= num {
break
}
protos, err := h().Peerstore().GetProtocols(id)
if err != nil {
continue
}
for _, proto := range protos {
if strings.HasPrefix(string(proto), "/libp2p/circuit/relay/") {
ch <- peer.AddrInfo{