39

Once the bitcoin client is connected to a machine (or multiple machines) on the bitcoin network, they can share information (e.g. the block-chain, IP addresses of other nodes, etc). I understand how this peer-to-peer architecture is robust to nodes joining/leaving/crashing and not relying on any central authority.

My question is: when I start my client, it has no information about the IP addresses of the other nodes, so how does it know who/where to connect to initially? How does one 'boot-strap' a peer-to-peer network?

33

The Bitcoin client has a number of sources that it uses to locate the network on initial startup. In order of importance:

1) The primary mechanism, if the client has ever run on this machine before and its database is intact, is to look at its database. It tracks every node it has seen on the network, how long ago it last saw it, and its IP address.

2) The client can use DNS to locate a list of nodes connected to the network. One such seed is bitseed.xf2.org. The client will resolve this and get a list of Bitcoin nodes.

3) The client has a list of semi-permanent nodes compiled into it.

4) The client can connect to a well-known IRC network, irc.lfnet.org, and find other nodes that way. (This method has been removed as of version 0.8.2)

5) It takes IP addresses from the commandline (-addnode).

  • 14
    5) It takes IP addresses from the commandline (-addnode). – Pieter Wuille Dec 4 '11 at 14:58
5

There are several bootstrap methods. I know of two:

  1. An specific IRC channel is joined by the client. In this channel, connected clients often broadcast their IP, to allow others to find them.
  2. There is a list of hard-coded IPs in the client binary, which the client will connect to bootstrap its network.
4

The connection method depends on the client.

Bitcoin Core will spend up to 11 seconds trying to connect to a peer in its database. If that doesn't work, it will query a DNS server (known as a DNS seed) to get addresses for peers the seed believes are active. If that doesn't work within 60 seconds, it will fallback to one of its hardcoded addresses. Once a connection is made to a remote peer, the local node will request more addresses from that remote peer.

Other clients may work differently---for example, BitcoinJ by default jumps straight to querying the DNS seeds. If that doesn't work, it will fallback to hardcoded addresses.

A few more details may be found in the Peer Discovery section of the Bitcoin.org Developer Guide.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.