Skip to content

Commit

Permalink
remove explicit peer
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeguglielmo committed Nov 16, 2023
1 parent 5b9370f commit a69b4fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions dht-cache/src/domocache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ impl DomoCache {
}
SwarmEvent::ConnectionEstablished { peer_id, connection_id, endpoint, .. } => {
println!("Connection established {peer_id:?}, {connection_id:?}, {endpoint:?}");
self.swarm
.behaviour_mut()
.gossipsub
.add_explicit_peer(&peer_id);
// self.swarm
// .behaviour_mut()
// .gossipsub
// .add_explicit_peer(&peer_id);
}
SwarmEvent::ConnectionClosed { peer_id, connection_id, endpoint, num_established: _, cause } => {
log::info!("Connection closed {peer_id:?}, {connection_id:?}, {endpoint:?} -> {cause:?}");
println!("Connection closed {peer_id:?}, {connection_id:?}, {endpoint:?} -> {cause:?}");
}
SwarmEvent::ListenerError { listener_id, error } => {
log::warn!("Listener Error {listener_id:?} -> {error:?}");
Expand Down Expand Up @@ -460,7 +460,8 @@ impl DomoCache {
let local = OffsetDateTime::now_utc();

for (peer, _) in list {
log::info!("MDNS for peer {peer} expired {local:?}");
println!("MDNS for peer {peer} expired {local:?}");
self.swarm.behaviour_mut().gossipsub.remove_explicit_peer(&peer);
}
}
SwarmEvent::Behaviour(crate::domolibp2p::OutEvent::Mdns(
Expand Down
2 changes: 1 addition & 1 deletion dht-cache/src/domolibp2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub async fn start(
Ok(behaviour)

})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(2 * crate::domocache::SEND_CACHE_HASH_PERIOD as u64)))
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(1)))
.build();


Expand Down

0 comments on commit a69b4fd

Please sign in to comment.