Peer Selection Metric

Hi!

I’m running a node and I tried observing the neighbourhood of this node in order to get a feel for how IPFS (or rather, libp2p) works.
What I now don’t understand is why some nodes (which I know to be online) with comparatively close Identifiers do not show up when issuing ipfs swarm peers while other, farther away (wrt. XOR distance) nodes do show up.

FYI, I calculated distances by feeding identifiers into the XOR function provided by libp2p. For example, the IDs
QmPBcMKHuZpN6HDEJ6TKRJvsh37u1oK2BfyNPGowvVCAbC and QmPC6CeopyPW5Zd7AogbtLyX852ikKczw2CnPTQvciR6B9 have a distance of
114545139385334970708164582957464818515709977098988240905961195283550328.

Best,
Sifgried

Thank you for the share!

So, this post is a bit old but I figure I should answer it anyways. This was likely due to https://github.com/libp2p/go-libp2p-kad-dht/issues/147 which was fixed in 0.4.17. Basically, we were bootstrapping by connecting to random peers in the DHT but we never actively tried to find nearby peers. This worked well when the network was small because we’d randomly connect to these peers anyways.

If you try this test again, you should see better results (after giving IPFS several minutes to completely bootstrap).