How does Nano's peer discovery work?
When a Nano node starts for the first time, it has to work out who to talk to. Nodes generally can be in flux so hard coding IP addresses is not the best idea.
Recently @gurghet added the initial peering code which implements node discovery for the Feeless node, similar to the official Nano node, explained below.
Previously, the Feeless node only accepted a single argument which was another node's IP address. I was using this to
connect to the official Nano node running on my PC, by setting it to localhost
when working on the Feeless node implementation.
The way Nano node discovery works in the official Nano implementation, and now in Feeless, is via a domain called
peering.nano.org
. Presumably the domain is owned by the Nano Foundation.
This domain resolves to multiple A
records:
Each one of these are a Nano node. Looking into these IP addresses, they belong to several different ISPs: Digital Ocean, Hetzner, Linode, CloudSigma, netcup and Choopa. On top of that they are located all around the world: India, Finland, United States, Switzerland, Netherlands, Japan, Germany and Australia.
I'm guessing these are nodes controlled by the Nano Foundation, or it could just be hand picked principal representatives, etc.
It looks very well distributed for new nodes to start with. If there's a problem with any of these cloud providers or country's Internet, a node can easily still start synchronizing with the other nodes.
A neat thing about set up is that the Nano Foundation can easily update any new initial nodes to their liking without having to create a new node release. They just need to update the DNS record.
Once a node is connected to a peer, and an exchange of handshakes happen, the peer sends more peers to that node via the Keepalive
message, seen below:
The message sends up to 8 peers back to the node, from there it can keep adding peers and so on.