Clone only needed KademliaPeer
s when yielding closest nodes #53
Open
Description
The implementation of RoutingTable::closest
calls KBucket::closest_iter
, where all peers of a bucket are cloned:
https://github.com/altonen/litep2p/blob/365330d0b1ff96796b7ac0a78cec197f6e79ca7e/src/protocol/libp2p/kademlia/bucket.rs#L105
This can be optimized by sorting entries in place, yielding references, and cloning only KademliaPeer
s that are returned from RoutingTable::closest
.