p2panda / aquadoggo

Node for the p2panda network handling validation, storage, aggregation and replication
GNU Affero General Public License v3.0
69 stars 5 forks source link

Dial all configured known relay and direct node addresses on schedule #622

Closed sandreae closed 2 months ago

sandreae commented 2 months ago

When a node is first launched it attempts to connect to any configured relay or direct node addresses, the steps are as follows:

1) register at all relay/rendezvous nodes for peer discovery and connections 2) connect to and initiate a replication sessions with all relay/rendezvous nodes 3) connect to and initiate a replication sessions with all direct nodes

If the device where a node is running is offline when the app starts, all of these steps will fail and no further connection attempts are made. Similarly, if the node loses connectivity after it started, connections will be dropped for good.

This PR implements a modest solution for points 2) an 3) above by adding a polling service to the EventLoop which attempts to (re)connect to all known peer addresses (relay or otherwise) every x seconds. A connection is only established if none already exist to the address in question. Replication sessions will be initiated with any peers that we successfully (re)connect to.

Finding a solution in the same situation for point 1) above is a little more involved, these changes seemed like easy low hanging fruit which brings greatly improved UX to node users, especially in situations where nodes run for long periods and connections may drop.

📋 Checklist