Skip to content
Open
15 changes: 14 additions & 1 deletion core/src/transport/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@
//!
//! The connection setup includes all protocol upgrades applied on the
//! underlying `Transport`.
// TODO: add example
//!
//! # Example
//!
//! ```no_run
//! use libp2p_core::{transport::MemoryTransport, Transport as _};
//! use libp2p_core::transport::{timeout::TransportTimeout, ListenerId};
//! use std::time::Duration;
//!
//! let base = MemoryTransport::default();
//! let mut timeout = TransportTimeout::new(base, Duration::from_secs(1));
//!
//! // Listen and dial as usual; the setup will be subject to timeouts.
//! let _ = timeout.listen_on(ListenerId::next(), "/memory/0".parse().unwrap());
//! ```

use std::{
error, fmt, io,
Expand Down
4 changes: 2 additions & 2 deletions misc/metrics/src/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use crate::protocol_stack;
const ALLOWED_PROTOCOLS: &[StreamProtocol] = &[
#[cfg(feature = "dcutr")]
libp2p_dcutr::PROTOCOL_NAME,
// #[cfg(feature = "gossipsub")]
// TODO: Add Gossipsub protocol name
// NOTE: Not including gossipsub here as users may configure custom protocol IDs
// via ConfigBuilder::protocol_id. Hard-coding defaults would misclassify such setups.
libp2p_identify::PROTOCOL_NAME,
libp2p_identify::PUSH_PROTOCOL_NAME,
#[cfg(feature = "kad")]
Expand Down
13 changes: 13 additions & 0 deletions swarm/src/handler/one_shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ where
}
}

impl<TInbound, TOutbound, TEvent> std::fmt::Debug for OneShotHandler<TInbound, TOutbound, TEvent>
where
TOutbound: OutboundUpgradeSend,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("OneShotHandler")
.field("pending_requests", &self.pending_requests())
.field("dial_negotiated", &self.dial_negotiated)
.field("dial_queue_len", &self.dial_queue.len())
.finish()
}
}

impl<TInbound, TOutbound, TEvent> ConnectionHandler for OneShotHandler<TInbound, TOutbound, TEvent>
where
TInbound: InboundUpgradeSend + Send + 'static,
Expand Down