Skip to content

Commit

Permalink
call bootstrap on new kademlia node connected
Browse files Browse the repository at this point in the history
  • Loading branch information
PanGan21 committed Nov 27, 2023
1 parent ea694e5 commit f492105
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f492105

Please sign in to comment.