Closed kasperisager closed 2 years ago
One gotcha is that swarm.join()
now always allocates, which wasn't previously the case. If a caller depends on swarm.join()
effectively acting as discovery.refresh()
, they risk unexpectedly allocating sessions that aren't cleaned up until swarm.leave()
is called.
Nice, LGTM from me, but will let @andrewosh do a quick pass also as this is quite critical
The
PeerDiscovery
instance is now never surfaced to the caller who instead gets back aPeerDiscoverySession
instance onswarm.join()
. Multiple independant sessions may be created with different options with the underlyingPeerDiscovery
instance determining based on reference counts whether it should act as server, client, or both. When the last session is destroyed, thePeerDiscovery
instance is also destroyed. ThePeerDiscovery
instance may also be destroyed directly usingswarm.leave()
per the existing flow.