Why does Bitcoin use a gossip protocol rather than a DHT for peer discovery? I believe that kademlia XOR distance helps shape the network topology so that peers are more evenly disturbed.
-
1What does 'peer lookup' mean? Bitcoin does not have any local data specific to a node, and every node needs to learn everything anyway. We have peer selection logic, but it optimizes for DoS protection robustness and propagation speed. What exactly would it use a DHT for?– Pieter WuilleMay 12, 2015 at 21:37
-
i think he's talking about the BitTorrent DHT implementation, which is used to find peers - Bittorrent's DHT stores IP addresses of peers downloading the torrent as values - although generally DHT's aren't used for that.– Luca MatteisMay 12, 2015 at 22:46
-
@NickODell i mean peer discover. Is that clear?– null_radixMay 13, 2015 at 21:31
-
@PieterWuille With XOR-Topology you have more evenly connected network. With Gossip peers that stay online for a long time tend to have more connection. Since almost every peer will know about it. But I'm not 100% sure about this so I'm asking here.– null_radixMay 13, 2015 at 21:54
1 Answer
DHTs are built so that nodes keep only a small portion of other nodes addresses in their routing table (the closest ones). This means that when you send a message to a DHT to put("foo", "bar"), only specific peers are going to see it (in fact as little as possible) and even fewer are going to store it. So if you want to do "peer lookup" using DHTs, it wouldn't work because nodes aren't programmed to send messages through a path to all nodes.
Also I think you may be confused with BitTorrent's DHT. They store IP addressed of peers downloading torrents as values of keys in the DHT. So in that sense, they do use the DHT to "lookup peers" downloading a specific torrent. BitTorrent is a different system than Bitcoin, which is not a file-transfer protocol, and therefore I don't see how a DHT can be useful to Bitcoin's design.
-
I edited the question to make it more clear. You can most certainly use a DHT like structure to select Peers. Its not quite a full DHT because we wouldn't be storing any hashes. May 14, 2015 at 19:00
-
your question is still not very clear. what are you trying to do? May 14, 2015 at 20:54
-
trying to find peers to connect to. you can do this with an greed algo (ie. ask a bootstraping peer to give you all the peers it knows about and so forth) or storing peers in k-buckets (DHT) and connecting to them on the basis of their XOR distance. Which should give you a "better" network topology. Is there any reason that bitcoin uses a greedy algo and not something? May 15, 2015 at 13:48
-
Actually DHTs don't say anything regarding "how to find peers". DHTs have a logic of understanding which peers to keep and which to reject, and the result is that you end up connecting to peers that are XOR closest to you. In terms of "how to find peers", the logic is similar to Bitcoin - just ask other peers about their routing table. Also, the XOR distance is useful for performing key lookups - it reduces to a minimum the number of hops to find peers storing a specific key - how would it be used in Bitcoin? May 15, 2015 at 16:01
-