Close#636
The PR updates the send logic to use a select with ctx.Done() and
t.p.ctx.Done(), ensuring the operation terminates gracefully. A test
case reproducing the issue is included in the PR for verification.
This removes dependencies on swarm/testing and the blank host.
1. swarm/testing really shouldn't be used at all except for internal
libp2p stuff.
2. The blank host should only be used in _very_ special cases (autonat,
mostly).
* - added PublishWithSk functionality on the Topic implementation
* - fixes after merge
* - complete refactor: used publishing options instead of a new function
* - added one more check in unit test
* - bugfix: use local variables instead of fields
* - renamed tests
That is, when MinTopicSize is used but not WithDiscovery,
Publish will keep waiting until MinTopicSize's condition is met.
At the moment, this is done by polling every 200ms.
In the future, the mechanism could be optimized to be event-based.
A TODO is left for that purpose.
Fixes#454.
* cleanup: fix vet failures and most staticcheck failures
* Fix remaining staticcheck failures
* Give test goroutines chance to exit early when context is canceled
Added PubSub.Join(topic) that returns a Topic object. This object can be Subscribed and Published to as well as to get a TopicEventHandler for topic events. This means that the Subscription object will no longer handle PeerEvents and that PubSub's Publish and Subscribe functions are deprecated.