OpenBazaar/OpenBazaar — pull request #909 by gubatron (2014-11-02 21:19:54+00:00)
Title: Fixing Kademlia's K constant.

The current number of 80 defeats the whole purpose of
Kademlia routing, specially since the network is so small,
if we get to have 3 buckets it's probably luck (out of possible 160 buckets
used for routing if the routing has been implemented correctly).

With a K=80, there's very little chance for bucket splits, which
means, each peer is always contacting all the nodes that it knows
for searches. The idea of having buckets which separate peers by
their XOR distance is that we can half the number of searches necessary
if all nodes are organized by these rules.

If we have smaller K sized lists (buckets), we'll start contacting less
peers and getting results a lot faster, as these peers get to ask less peers
in an efficient way.

The replacement cache max size has also been reduced to 32.
The idea of this cache is to hold good nodes that can't be added to a bucket list,
they away there as bad nodes are purged out. It should be hard to hit this cache
as the routing table splits into more and more buckets, only nodes that happen to be
very very close (XOR wise) will be waiting here, as our buckets should be full if we have
anyone here.