tristanls / discover

Node discovery based on Kademlia DHT protocol.
MIT License
69 stars 10 forks source link

Implement non-kBucket LRU cache #6

Closed tristanls closed 10 years ago

tristanls commented 10 years ago

In tristanls/tart-ansible#2 a corner case is highlighted that exposes how relevant contact information may be rejected from being stored inside Discover and be not available despite that it may be needed.

The corner case occurs when a new contact is being added to a full kBucket. If that happens, the addition will be suspended and existing contacts will be pinged for liveness. If all the existing contacts respond to the ping, the addition will be rejected.

The purpose of the non-kBucket LRU cache is to make contacts available in case the kBucket is full and contacts are being pinged. Additionally, the purpose is also to make contacts available, even if they are rejected from being added to the kBucket.

To clarify, the contacts, even if rejected, are still available for lookup in the DHT. However, if they are rejected, it takes at least one network round-trip to retrieve the contact from the DHT instead of being locally available.