What protocols or algorithms are Bitcoin clients using in order to find their peers? I learnt that BitTorrent clients may rely on central computers called trackers. Do Bitcoin clients need any kind of central servers or nodes in order to operate?

up vote 94 down vote accepted

Bitcoin clients use several methods to locate other clients. The primary method is a list of nodes from a previous connection to the network. The works very well for everything but your first connection or a connection after a very long period of disconnection.

For the case where you have no previous known IPs or they aren't usable, the primary fallback method is by DNS seeds. Several host names (such as dnsseed.bluematt.me) are maintained that resolve to a list of IP addresses known to be running nodes. Should that fail, the client has a list of IP addresses believed to point to stable nodes hard-coded into it.

One method that used to be used, but that has since been abandoned, was having the clients locate each other using an IRC server. That worked similar to a BitTorrent tracker.

Once you are connected to the network, you will begin to receive lists of IP addresses and ports of known clients.

  • 4
    When the Bitcoin.org client needs to discover peers, DNS seeds is the default for the client v0.6 and above. IRC was the default for earlier versions. – Stephen Gornick May 1 '12 at 15:10
  • when you guys mention IRC, what IRC network exactly? – knocte Apr 14 '13 at 12:52
  • 1
    @knocte It used to use irc.lfnet.org, joining a random channel between #bitcoin00 and #bitcoin99. – David Schwartz Apr 14 '13 at 13:03
  • 1
    so if lfnet.org went down, that was a single point of failure? what now, who dictates what are the DNS names to lookup? – knocte Apr 14 '13 at 14:12
  • 2
    @Taiko DNS poisoning has no effect on connections to hard coded IPs. You are right that an entity that controls your Internet access can break your ability to use bitcoin, just as it can break your ability to use any other Internet service. (Bitcoin is especially resilient, however, because just one leak saves everyone.) – David Schwartz Oct 24 '17 at 18:37

There's a couple of methods the client can use. However, unlike David's very good answer, I'll talk about them in chronological order:

  • The number one way that clients learn about other clients is by connecting to another client and issuing the 'getaddr' command. The standard client has always had that ability. However, there's a problem with this - how do you learn about client #1?
  • IRC seeding. This is something that's been in since the first version too. It was simple to implement, but ultimately didn't scale. The first version connected to freenode. Then, bitcoin nodes started getting k-lined. Later versions connected to lfnet. Then, lfnet went down, and IRC support was removed entirely. DNS was around by this point, so that was fine.
  • IP addresses of well known nodes. This has been in the client since June 2010. Still in the Bitcoin client, though the exact IP addresses change every so often.
  • DNS seeding. This has been in the client since March 2011. This is easier to scale, because DNS is already built to handle tens of thousands of connections.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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