mafintosh / discovery-swarm

A network swarm that uses discovery-channel to find peers
MIT License
375 stars 57 forks source link

Add opts.keepExistingConnections #63

Closed hackergrrl closed 4 years ago

hackergrrl commented 4 years ago

This causes discovery-swarm to prefer existing connections when the flag is set, as opposed to the default logic which will destroy a good UTP (or TCP) connection in favor of a new TCP connection.

This change was motivated by the needs of mapeo-core, which relies on the same connection being used for the duration of a sync between two peers. UTP connections getting swapped out for TCP ones mid-sync was causing us a lot of problems. This would also appear in localhost tests, where an e.g. IPv4 connection began and then an IPv6 connection caused the previous one to be dropped.

Implemented as opt-in, so that this module's many downstream packages aren't affected.

okdistribute commented 4 years ago

LGTM. In general would be great to have tests but it is a small PR and this repository is going to get deprecated in favor of hyperswarm anyway. @mafintosh ?

mafintosh commented 4 years ago

Ya LGTM. I’d strongly suggest to move to hyperswarm asap if you can as no one is really maintaining this atm (and hs is better in every way).