Skip to content

Commit

Permalink
add link in doc, handle successful bootstrap, reanable polling
Browse files Browse the repository at this point in the history
  • Loading branch information
PanGan21 committed Dec 2, 2023
1 parent 8604f72 commit 179db10
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ where
/// invoked at regular intervals based on the configured bootstrapping interval.
/// The bootstrapping interval is used to call bootstrap periodically
/// to ensure a healthy routing table.
/// > See bootstrap_interval field in Config.
/// > See [`Config::bootstrap_interval`] field in Config.

Check failure on line 911 in protocols/kad/src/behaviour.rs

View workflow job for this annotation

GitHub Actions / Check rustdoc intra-doc links

public documentation for `bootstrap` links to private item `Config::bootstrap_interval`
pub fn bootstrap(&mut self) -> Result<QueryId, NoKnownPeers> {
let local_key = self.kbuckets.local_key().clone();
let info = QueryInfo::Bootstrap {
Expand Down Expand Up @@ -1435,6 +1435,8 @@ where
step.last = true;
};

self.any_bootstrap_successful = true;

Some(Event::OutboundQueryProgressed {
id: query_id,
stats: result.stats,
Expand Down Expand Up @@ -2084,10 +2086,7 @@ where
fn maybe_bootstrap(&mut self) {
if self.current_automated_bootstrap.is_none() {
match self.bootstrap() {
Ok(query_id) => {
self.current_automated_bootstrap = Some(query_id);
self.any_bootstrap_successful = true;
}
Ok(query_id) => self.current_automated_bootstrap = Some(query_id),
Err(_) => self.current_automated_bootstrap = None,
}
}
Expand Down Expand Up @@ -2519,9 +2518,7 @@ where
if let Poll::Ready(()) = Pin::new(&mut bootstrap_timer).poll(cx) {
if let Some(interval) = self.bootstrap_interval {
bootstrap_timer.reset(interval);
if !self.any_bootstrap_successful {
self.maybe_bootstrap();
}
self.maybe_bootstrap();
}
}
self.bootstrap_timer = Some(bootstrap_timer);
Expand Down

0 comments on commit 179db10

Please sign in to comment.