DevelopersP2pDiscovery
P2p

Discovery

Discovery is the process of finding other nodes to connect with.

We do this through the following 3 systems:

Overview of methods

From a technical perspective all of these methods operate very differently so it's important to understand the differences between them when making changes to the P2P system.

The relay and manual entry method both require the P2P system to be given an upfront list of peers to connect to, whereas the mDNS system is able to discover them itself. For the relay these peers comes from the instances table in the database and for manual entry these peers comes from the node configuration file.

A quirk manual entry is that when we attempt a connection we don't know the remote nodes identity or metadata prior to connecting. We instead establish a full connection to ask for remote nodes information (RemoteIdentity and metadata) after which we treat it as discovered.

This table summarises the differences between the methods:

mDNSRelayManual
Requires upfront knowledge of existence of peerNoYesYes
Knows connection info (metadata, RemoteIdentity) ahead of connectionYesYesNo

Manually provided peers

The user can manually provide a set of SocketAddr's or FQDN's and the P2P system will attempt to connect to them. If a domain is provided the P2P system will resolve it to an IP address and then attempt to connect to that address.

This feature primarily exists for usage with Docker as mDNS discovery does not work correctly, however it could be useful for working around difficult network setups. It's important to note that you must use port forwarding and set a static port for the node when using this feature.

When you add a manual peer it will not show up in the nodes list until the P2P system is able to establish a connection. This is because without having established a connection the system is unable to determine the remote nodes identity or metadata which is required for it to be considered discovered.