From f49210542da2a1d56b4e98072bd6fd271e82a0cc Mon Sep 17 00:00:00 2001 From: PanGan21 Date: Mon, 27 Nov 2023 17:34:41 +0200 Subject: [PATCH] call bootstrap on new kademlia node connected --- protocols/kad/src/behaviour.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 677ce44541b..d55cb1380bd 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -575,6 +575,7 @@ where }; match entry.insert(addresses.clone(), status) { kbucket::InsertResult::Inserted => { + self.on_new_kademlia_node(); self.queued_events.push_back(ToSwarm::GenerateEvent( Event::RoutingUpdated { peer: *peer, @@ -1302,6 +1303,7 @@ where let addresses = Addresses::new(a); match entry.insert(addresses.clone(), new_status) { kbucket::InsertResult::Inserted => { + self.on_new_kademlia_node(); let event = Event::RoutingUpdated { peer, is_new_peer: true, @@ -2065,6 +2067,10 @@ where } } + fn on_new_kademlia_node(&mut self) { + let _ = self.bootstrap(); + } + /// Preloads a new [`Handler`] with requests that are waiting to be sent to the newly connected peer. fn preload_new_handler( &mut self,