Skip to content

Commit

Permalink
disconnect peers
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeguglielmo committed Nov 22, 2023
1 parent 97982b5 commit a3721f7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dht-cache/src/domocache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,24 @@ impl DomoCache {
}

pub fn remove_connections_of_peers(&mut self) {
let mut to_remove: Vec<String> = Vec::new();
for (peer_id, peer_data) in self.peers_caches_state.iter() {
if peer_data.publication_timestamp < (utils::get_epoch_ms() - 2 * 1000 * u128::from(SEND_CACHE_HASH_PERIOD)){
println!("DISCONNECTING {peer_id}");
to_remove.push(peer_id.clone());
if let Ok(peer_id) = PeerId::from_str(peer_id) {
let res = self.swarm.disconnect_peer_id(peer_id);
if let Ok(res) = self.swarm.disconnect_peer_id(peer_id) {
println!("DISCONNECTING {peer_id}");
}
}
}
}

for to_r in to_remove {
self.peers_caches_state.remove(&to_r);
}



}

pub fn print_peers_cache(&self) {
Expand Down

0 comments on commit a3721f7

Please sign in to comment.