Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kad): compute jobs_query_capacity accurately #5148

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Make it mandatory to provide protocol names when creating a `kad::Config`.
Deprecate `kad::Config::default()`, replaced by `kad::Config::new(StreamProtocol)`.
See [PR 5122](https://github.com/libp2p/rust-libp2p/pull/5122).
- Compute `jobs_query_capacity` accurately.
See [PR 5148](https://github.com/libp2p/rust-libp2p/pull/5148).

## 0.45.3

Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2502,14 +2502,14 @@ where
// Run the periodic provider announcement job.
if let Some(mut job) = self.add_provider_job.take() {
let num = usize::min(JOBS_MAX_NEW_QUERIES, jobs_query_capacity);
for _ in 0..num {
for i in 0..num {
if let Poll::Ready(r) = job.poll(cx, &mut self.store, now) {
self.start_add_provider(r.key, AddProviderContext::Republish)
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
} else {
jobs_query_capacity -= i;
break;
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
}
}
jobs_query_capacity -= num;
self.add_provider_job = Some(job);
}

Expand Down
Loading