go-libp2p-pubsub
go-libp2p-pubsub copied to clipboard
PubSub Discovery boostrapping does not return as fast as it could
Currently when we Publish to a topic and require boostrapping (e.g. passing in WithReadiness(MinTopicSize(5))) we wait until a discovery query completes before checking again to see if we're ready.
https://github.com/libp2p/go-libp2p-pubsub/blob/534fe2f382d8dd75dab89ddb0760542546c9f24e/discovery.go#L268-L274
This is not ideal since it's possible that we could passively discover peers (MDNS, another protocol causing a connection, etc.) during a long discovery process.
Some options:
- Periodically check the "ready" condition instead
- There's a balance between how quickly we return and performance. The more frequently we poll, the faster we return and the more resources we consume. A backoff layer could help here, but that's just more complexity
- Use our internal peer discovery events and check every time we get a new peer
- Assumes that the "ready" condition is static (e.g. find 5 peers), if the condition is dynamic then the events won't help us
@vyzo any thoughts here?
Yeah, it would be nice to factor out of band connections. Either approach works, polling probably easier to work with.