Skip to content

Commit

Permalink
Add DCUTR event debug logging to swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreae committed Jun 22, 2024
1 parent 8ff38d2 commit a2ea5c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion aquadoggo/src/network/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ pub enum Event {
RendezvousClient(rendezvous::client::Event),
#[allow(dead_code)]
RendezvousServer(rendezvous::server::Event),
#[allow(dead_code)]
Dcutr(dcutr::Event),
Peers(peers::Event),
Void,
Expand Down
15 changes: 14 additions & 1 deletion aquadoggo/src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use libp2p::multiaddr::Protocol;
use libp2p::rendezvous::Registration;
use libp2p::swarm::dial_opts::DialOpts;
use libp2p::swarm::SwarmEvent;
use libp2p::{identify, mdns, relay, rendezvous, Multiaddr, PeerId, Swarm};
use libp2p::{dcutr, identify, mdns, relay, rendezvous, Multiaddr, PeerId, Swarm};
use log::{debug, info, trace, warn};
use tokio::task;
use tokio::time::interval;
Expand Down Expand Up @@ -196,6 +196,7 @@ impl EventLoop {
SwarmEvent::Behaviour(Event::RendezvousClient(event)) => self.handle_rendezvous_client_events(&event).await,
SwarmEvent::Behaviour(Event::Peers(event)) => self.handle_peers_events(&event).await,
SwarmEvent::Behaviour(Event::RelayClient(event)) => self.handle_relay_client_events(&event).await,
SwarmEvent::Behaviour(Event::Dcutr(event)) => self.handle_dcutr_events(&event).await,
event => self.handle_swarm_events(event).await,

}
Expand Down Expand Up @@ -462,6 +463,18 @@ impl EventLoop {
}
}

async fn handle_dcutr_events(&mut self, event: &dcutr::Event) {
match &event.result {
Ok(connection_id) => {
info!(
"{}({}) upgraded to direct connection",
event.remote_peer_id, connection_id
);
}
Err(e) => debug!("Direct connection upgrade error: {}", e),
}
}

async fn handle_swarm_events(&mut self, event: SwarmEvent<Event>) {
match event {
SwarmEvent::ConnectionEstablished {
Expand Down

0 comments on commit a2ea5c1

Please sign in to comment.