go-libp2p
go-libp2p copied to clipboard
add a utility function to regularly question a Discoverer for peers
The idea is the following:
- We construct an
AutoRelaywith apeerChan <-chan peer.AddrInfo. Peers sent on this channel are potential candidates for v2 relays. - We then regularly query the DHT for new peers, and send those on the channel.
This avoids a circular dependency between the DHT (which depends on the host.Host), and AutoRelay: You can now construct your host (with AutoRelay) first, just passing in the peerChan. Once the host and the DHT are constructed, you can now start filling that chan.
I'm not sure if the implementation here makes sense though. We're regularly restarting FindPeers. Instead, maybe we can just continue receiving values from that chan?