PhysarumSM / common

Common code
Apache License 2.0
0 stars 0 forks source link

Attempt reconnection to bootstraps when connection is lost #12

Closed t-lin closed 4 years ago

t-lin commented 4 years ago

Currently, if the bootstrap restarts, peers completely lose the connection to it. This means when the bootstrap restart, no peer are connected to it. Every former peer must restart to reconnect.

Bootstraps (by definition) should be nodes with long uptime. So it should be safe to continuously try and reconnect to these specific set of nodes, because we assume they'll come back soon. This problem is especially an issue now that the bootstraps are also ping-monitor nodes.

Can use the notifier function to receive notification of when bootstraps are disconnected, and attempt to reconnect (w/ exponential backoff up to some max backoff time, then just keep re-trying at the max backoff time forever?). See Multi-Tier-Cloud/monitoring@eff5b0fe4e96742be42938bde7c26c16458daa6a for example of the notifier functions, or https://godoc.org/github.com/libp2p/go-libp2p-core/network#NotifyBundle.

Ideally, the solution should be built into p2pnode so other services don't have to worry about duplicating the code or handling this case.