I thought I might put some info together for those who may be interested in the technology behind discovering other nodes on the network.
As you may know, almost every cryptocurrency today operates on a peer to peer network.
This is the the strength of the network having each node decentralised.
But how does it work exactly?
How does a node (your client wallet) discover any of the other nodes if you have only just downloaded the client fresh and it has never seen those node before?
Well, there are a few methods available.
- In the client there are some hard coded DNSSeed nodes
- In the client, there are some hard coded nodes
- By adding -seednode to your startup
- By adding -addnode to your startup
- By adding -connect to your startup
- Reading from peers.dat
- Retrieve a list of hosts via IRC (obsolete)
When you first launch your wallet, it will use one of these above methods to attempt to connect to other nodes on the network. If it is able to make a connection with 1 or more nodes, it will request a list of other clients that may be reachable.
These nodes are written into the source code of the software and are updated periodically to reflect the growth of the network
DNSSeed nodes are usually operated under a system of trust. and relies on those hard coded DNSSeed nodes to always be available.
For users, the cool thing about DNSSeed nodes is that they maintain a dynamic list of available hosts along with their reliability.
It is constantly checking and discovering nodes on the network and measuring their reliability
When your client first connects to the DNSSeeder, the DNSSeeder will return a list of reliable nodes that your client can connect with.
Once that connection is made and the list returned, the job is done, and your client would not normally connect again.
Your client will store those returned addresses in the peers.dat file and will then use them to connect out onto the network.
These nodes are encoded and written into the source code of the software and are updated periodically to reflect the growth and changing network. These are essentially full nodes, but are encoded into the wallet so that other clients can find nodes to connect to. They are also operated under a system of trust. and relies on those hard coded nodes to always be available. If the nodes become unavailable, they become candidates to be removed from the source code.
This is similar to Option 1. except that you can you use this method to connect to other DNSSeed nodes that are not included in the main wallet.
-seednode=<ip address> commandline option
seednode=<ip address> conf file
Your client will connect to these servers to retrieve addresses, and disconnect.
You have probably seen this before, where new crypto coin developers havent established a network other than than the genesis node (first node). As the network has not been established, you are requested to add in nodes for your client to connect to using either
-addnode=<ip address> from the commandline
addnode=<ip address> in the conf file
Your client will connect to and attempt to keep the connection open. It will use this connection to request addresses from these nodes.
This method establishes a connection only to the listed nodes
-connect=<ip address> from the commandline
connect=<ip address> in the conf file
Peers.dat is not directly editable, and is used by your client once it has established a connection to the network. Periodically the client will save a list of addresses to the file. If you have valid addresses in the peers.dat file, your client will read this file and use these to connect to the network
This is now an obsolete method, but is worth mentioning.
Clients would look to the IRC server for a list of active nodes.
Interestingly, the Electrum Servers can use this method to announce availability.
[ Work In Progress - Ask any questions and i will update the OP ]