Skip to content

Commit

Permalink
src/query/peers/closest: Have iterator consider alpha peers at init
Browse files Browse the repository at this point in the history
To allign with the Kademlia paper this commit makes the
`ClosestPeersIter` consider the closest alpha peers at initialization,
instead of `num_results` (which is equal to the k-value).

Aligning with the paper also applies aligning with the libp2p Golang
implementation as well as the xlattice specification.
  • Loading branch information
mxinden committed Apr 1, 2020
1 parent cfe4194 commit dd87819
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion protocols/kad/src/query/peers/closest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl ClosestPeersIter {
let state = PeerState::NotContacted;
(distance, Peer { key, state })
})
.take(config.num_results));
.take(ALPHA_VALUE.into()));

// The iterator initially makes progress by iterating towards the target.
let state = State::Iterating { no_progress : 0 };
Expand Down

0 comments on commit dd87819

Please sign in to comment.