go-libp2p-pubsub icon indicating copy to clipboard operation
go-libp2p-pubsub copied to clipboard

PubSub Discovery boostrapping does not return as fast as it could

Open aschmahmann opened this issue 6 years ago • 1 comments

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:

  1. 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
  2. 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?

aschmahmann avatar Nov 04 '19 23:11 aschmahmann

Yeah, it would be nice to factor out of band connections. Either approach works, polling probably easier to work with.

vyzo avatar Nov 05 '19 09:11 vyzo