Skip to content

Commit f600f7a

Browse files
rubdosmxinden
andauthored
protocols/kad: Fix number of remaining bootstrap requests. (#2125)
Fixes #2121 Co-authored-by: Max Inden <[email protected]> Co-authored-by: @izolyomi
1 parent 99da27b commit f600f7a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

protocols/kad/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

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

16+
- Return correct number of remaining bootstrap requests (see [PR 2125]).
17+
1618
[PR 2087]: https://github.com/libp2p/rust-libp2p/pull/2087
1719
[PR 2120]: https://github.com/libp2p/rust-libp2p/pull/2120
20+
[PR 2125]: https://github.com/libp2p/rust-libp2p/pull/2125
1821

1922
# 0.30.0 [2021-04-13]
2023

protocols/kad/src/behaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ where
11131113
}).collect::<Vec<_>>().into_iter()
11141114
});
11151115

1116-
let num_remaining = remaining.len().saturating_sub(1) as u32;
1116+
let num_remaining = remaining.len() as u32;
11171117

11181118
if let Some(target) = remaining.next() {
11191119
let info = QueryInfo::Bootstrap {

protocols/kad/src/behaviour/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ fn bootstrap() {
196196
}
197197
first = false;
198198
if ok.num_remaining == 0 {
199+
assert_eq!(
200+
swarm.behaviour_mut().queries.size(), 0,
201+
"Expect no remaining queries when `num_remaining` is zero.",
202+
);
199203
let mut known = HashSet::new();
200204
for b in swarm.behaviour_mut().kbuckets.iter() {
201205
for e in b.iter() {

0 commit comments

Comments
 (0)