Skip to content

Commit

Permalink
fix(libp2p): remove deprecated development_transport
Browse files Browse the repository at this point in the history
Pull-Request: #4732.
  • Loading branch information
mxinden authored Oct 26, 2023
1 parent fd7b5ac commit e00cb53
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 89 deletions.
3 changes: 3 additions & 0 deletions libp2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- Remove deprecated `libp2p-wasm-ext`.
Users should use `libp2p-websocket-websys` instead.
See [PR 4694](https://github.com/libp2p/rust-libp2p/pull/4694).
- Remove deprecated `development_transport`.
Use `libp2p::SwarmBuilder` instead.
See [PR 4732](https://github.com/libp2p/rust-libp2p/pull/4732).

## 0.52.4

Expand Down
88 changes: 0 additions & 88 deletions libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,91 +170,3 @@ pub use self::transport_ext::TransportExt;
pub use libp2p_identity as identity;
pub use libp2p_identity::PeerId;
pub use libp2p_swarm::{Stream, StreamProtocol};

/// Builds a `Transport` based on TCP/IP that supports the most commonly-used features of libp2p:
///
/// * DNS resolution.
/// * Noise protocol encryption.
/// * Websockets.
/// * Yamux for substream multiplexing.
///
/// All async I/O of the transport is based on `async-std`.
///
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[deprecated(note = "Use `libp2p::SwarmBuilder` instead.")]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "tcp",
feature = "dns",
feature = "websocket",
feature = "noise",
feature = "yamux",
feature = "async-std",
))]
pub async fn development_transport(
keypair: identity::Keypair,
) -> std::io::Result<core::transport::Boxed<(PeerId, core::muxing::StreamMuxerBox)>> {
let transport = {
let dns_tcp = dns::async_std::Transport::system(tcp::async_io::Transport::new(
tcp::Config::new().nodelay(true),
))
.await?;
let ws_dns_tcp = websocket::WsConfig::new(
dns::async_std::Transport::system(tcp::async_io::Transport::new(
tcp::Config::new().nodelay(true),
))
.await?,
);
dns_tcp.or_transport(ws_dns_tcp)
};

Ok(transport
.upgrade(core::upgrade::Version::V1)
.authenticate(noise::Config::new(&keypair).unwrap())
.multiplex(yamux::Config::default())
.timeout(std::time::Duration::from_secs(20))
.boxed())
}

/// Builds a `Transport` based on TCP/IP that supports the most commonly-used features of libp2p:
///
/// * DNS resolution.
/// * Noise protocol encryption.
/// * Websockets.
/// * Yamux for substream multiplexing.
///
/// All async I/O of the transport is based on `tokio`.
///
/// > **Note**: This `Transport` is not suitable for production usage, as its implementation
/// > reserves the right to support additional protocols or remove deprecated protocols.
#[deprecated(note = "Use `libp2p::SwarmBuilder` instead.")]
#[cfg(all(
not(target_arch = "wasm32"),
feature = "tcp",
feature = "dns",
feature = "websocket",
feature = "noise",
feature = "yamux",
feature = "tokio",
))]
pub fn tokio_development_transport(
keypair: identity::Keypair,
) -> std::io::Result<core::transport::Boxed<(PeerId, core::muxing::StreamMuxerBox)>> {
let transport = {
let dns_tcp = dns::tokio::Transport::system(tcp::tokio::Transport::new(
tcp::Config::new().nodelay(true),
))?;
let ws_dns_tcp = websocket::WsConfig::new(dns::tokio::Transport::system(
tcp::tokio::Transport::new(tcp::Config::new().nodelay(true)),
)?);
dns_tcp.or_transport(ws_dns_tcp)
};

Ok(transport
.upgrade(core::upgrade::Version::V1)
.authenticate(noise::Config::new(&keypair).unwrap())
.multiplex(yamux::Config::default())
.timeout(std::time::Duration::from_secs(20))
.boxed())
}
1 change: 0 additions & 1 deletion libp2p/src/tutorials/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,3 @@
//! [`Transport`]: crate::core::Transport
//! [`PeerId`]: crate::core::PeerId
//! [`Swarm`]: crate::swarm::Swarm
//! [`development_transport`]: crate::development_transport

0 comments on commit e00cb53

Please sign in to comment.