Roman Borschel 09f54df44d
Kademlia: Optimise iteration over closest keys / entries. (#1117)
* Kademlia: Optimise iteration over closest entries.

The current implementation for finding the entries whose keys are closest
to some target key in the Kademlia routing table involves copying the
keys of all buckets into a new `Vec` which is then sorted based on the
distances to the target and turned into an iterator from which only a
small number of elements (by default 20) are drawn.

This commit introduces an iterator over buckets for finding the closest
keys to a target that visits the buckets in the optimal order, based on
the information contained in the distance bit-string representing the
distance between the local key and the target.

Correctness is tested against full-table scans.

Also included:

  * Updated documentation.
  * The `Entry` API was moved to the `kbucket::entry` sub-module for
    ease of maintenance.
  * The pending node handling has been slightly refactored in order to
    bring code and documentation in agreement and clarify the semantics
    a little.

* Rewrite pending node handling and add tests.
2019-05-22 14:49:38 +02:00
..
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00
2019-05-15 16:50:43 +02:00