libp2p / js-libp2p-kad-dht

JavaScript implementation of the DHT for libp2p
https://libp2p.io
Other
141 stars 60 forks source link

dht.provide fails if any closest peer is blacklisted #105

Open kumavis opened 5 years ago

kumavis commented 5 years ago

reproduction / error flow

https://github.com/libp2p/js-libp2p-kad-dht/blob/9db17eb85cc9dc011b7aa2b710576a00ef7fda9e/src/index.js#L530-L542

suggestions:

kumavis commented 5 years ago

for reference my peers are usually blacklisted for "no transport for peer"

jacobheun commented 5 years ago

Since the network is still fairly unstable having peers in the dht that are no longer dialable is going to be an issue we need to address. The blacklisting is likely due to this.

The provide shouldn't ignore the errors, I think it should continue trying further peers until it hits kValue (20) peers. Also, if we fail to connect to the peer they should probably get removed from the table or at least penalized up to some threshold before removal.

If we don't provide to enough peers we risk findProviders having a higher failure rate for other peers.

Right now getClosestProviders returns only kValue peers. It would be great to be able to continue to pull from it until we've messaged enough peers.

kumavis commented 5 years ago

was also encountering this here https://github.com/libp2p/js-libp2p-kad-dht/blob/ddf80fed9ca7e8b1ec096f3160535aa3fdb45b50/src/private.js#L559