Skip to content

Commit

Permalink
Return the correct number of remaining bootstrap requests.
Browse files Browse the repository at this point in the history
Fixes #2121

Co-authored-by: Max Inden <[email protected]>
Co-authored-by: @izolyomi
  • Loading branch information
rubdos and mxinden committed Jul 9, 2021
1 parent 05a4b16 commit 8729fd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@

- Remove false `debug_assert` on `connected_peers` (see [PR 2120]).

- Return correct number of remaining bootstrap requests (see [PR 2125]).

[PR 2087]: https://github.com/libp2p/rust-libp2p/pull/2087
[PR 2120]: https://github.com/libp2p/rust-libp2p/pull/2120
[PR 2125]: https://github.com/libp2p/rust-libp2p/pull/2125

# 0.30.0 [2021-04-13]

Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ where
}).collect::<Vec<_>>().into_iter()
});

let num_remaining = remaining.len().saturating_sub(1) as u32;
let num_remaining = remaining.len() as u32;

if let Some(target) = remaining.next() {
let info = QueryInfo::Bootstrap {
Expand Down
4 changes: 4 additions & 0 deletions protocols/kad/src/behaviour/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ fn bootstrap() {
}
first = false;
if ok.num_remaining == 0 {
assert_eq!(
swarm.behaviour_mut().queries.size(), 0,
"Expect no remaining queries when `num_remaining` is zero.",
);
let mut known = HashSet::new();
for b in swarm.behaviour_mut().kbuckets.iter() {
for e in b.iter() {
Expand Down

0 comments on commit 8729fd8

Please sign in to comment.