How do distributed applications (bitcoin, torrents ...) find each other?

22

How are distributed / decentralized software capable of connecting and finding other machines running the same software?

In Bitcoin, for example, how do "Full Nodes" meet each other? How does he find "another wallet" to communicate?

Some decentralized software, such as Torrent, use an intermediary, unless misleading are called Trackers, which allow you to find each other. They seem to act like a DNS, roughly , so as to get address from those who have the downloaded file and can send it to you.

However, if a platform is distributed, there is no central server for information, how the heck can it find others? For me, in my conception there will always be an "intermediary", to enable one to find others, am I right? Is there another way to enable "distributed" application connections?

    
asked by anonymous 18.03.2017 / 22:38

1 answer

17

In the case of the Bitcoin protocol specifically, there is no intermediary for a client on the network to find others to connect to. A Bitcoin client, upon startup, will try to use some methods, in order, to discover other nodes on the network. These methods are as follows:

  • All nodes maintain a list of other nodes known to them, and preferentially connect to them at startup. This list contains all the nodes it has already connected to.

    The protocol also enables a node to ask another node for information about the active nodes it knows, through getaddr . Clients send this message to the nodes to which they connect, in order to increase their list of known nodes.

    If the client has never been online before, he does not yet have any IPs in his list of known nodes, so he'll need to get one using the next method.

  • DNS queries: There is a list of domains maintained for the sole purpose of providing a list of IPs that are known to be running Bitcoin network nodes, and these domains are embedded in the Bitcoin client code. So just a DNS query on these domains to have a list of the initial nodes to connect to, and from them to increase the local base of known nodes. You can see the specific code , and the excerpt where the client does the query ;

  • There is also a list of IPs of the Bitcoin network nodes (hardcoded) in the code, which will be used if all other methods fail. This list can be seen in that part of the code , and it is used here ;
  • The user can also start his client by passing a list of IP's of nodes to which he should initially try to connect, but in this case you would have to know the IP of at least one node that already exists. This is done using the -addnode=<ip> parameter. A list of available parameters can be viewed here .

Note: This response and the links to the code in GitHub refer to the 0.14.2 version.

    
16.07.2017 / 00:08