From 179db100f544857d2c2b82ac448bbe6966799210 Mon Sep 17 00:00:00 2001 From: PanGan21 Date: Sat, 2 Dec 2023 12:36:41 +0200 Subject: [PATCH] add link in doc, handle successful bootstrap, reanable polling --- protocols/kad/src/behaviour.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index d41cadffe72..f9d16ab7dab 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -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. pub fn bootstrap(&mut self) -> Result { let local_key = self.kbuckets.local_key().clone(); let info = QueryInfo::Bootstrap { @@ -1435,6 +1435,8 @@ where step.last = true; }; + self.any_bootstrap_successful = true; + Some(Event::OutboundQueryProgressed { id: query_id, stats: result.stats, @@ -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, } } @@ -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);