From b1cdf8d4bbc994049880ca85535d1219297777dd Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 1 May 2023 04:25:52 +0200 Subject: [PATCH] feat(yamux): rename symbols to follow module-based naming convention Implements our naming convention for the `libp2p-yamux` crate. Related: #2217. Pull-Request: #3852. --- Cargo.lock | 2 +- examples/autonat/src/bin/autonat_client.rs | 2 +- examples/autonat/src/bin/autonat_server.rs | 2 +- examples/chat-example/src/main.rs | 2 +- examples/dcutr/src/main.rs | 2 +- .../distributed-key-value-store/src/main.rs | 2 +- examples/file-sharing/src/network.rs | 2 +- examples/identify/src/main.rs | 2 +- examples/ipfs-private/src/main.rs | 6 +- examples/metrics/src/main.rs | 2 +- examples/ping-example/src/main.rs | 2 +- examples/relay-server/src/main.rs | 2 +- examples/rendezvous/src/bin/rzv-discover.rs | 2 +- examples/rendezvous/src/bin/rzv-identify.rs | 2 +- examples/rendezvous/src/bin/rzv-register.rs | 2 +- examples/rendezvous/src/main.rs | 2 +- interop-tests/src/bin/ping.rs | 4 +- libp2p/Cargo.toml | 2 +- libp2p/src/lib.rs | 4 +- muxers/yamux/CHANGELOG.md | 8 ++ muxers/yamux/Cargo.toml | 2 +- muxers/yamux/src/lib.rs | 110 ++++++++++-------- muxers/yamux/tests/compliance.rs | 8 +- protocols/dcutr/tests/lib.rs | 2 +- protocols/kad/src/behaviour/test.rs | 2 +- protocols/perf/Cargo.toml | 2 +- protocols/perf/src/bin/perf-client.rs | 2 +- protocols/perf/src/bin/perf-server.rs | 2 +- protocols/relay/tests/lib.rs | 2 +- swarm-test/Cargo.toml | 2 +- swarm-test/src/lib.rs | 4 +- swarm/src/lib.rs | 2 +- transports/pnet/tests/smoke.rs | 2 +- transports/quic/tests/smoke.rs | 2 +- transports/tls/tests/smoke.rs | 2 +- 35 files changed, 108 insertions(+), 92 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 327ed18486e..890eb5583ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3078,7 +3078,7 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.43.0" +version = "0.43.1" dependencies = [ "async-std", "futures", diff --git a/examples/autonat/src/bin/autonat_client.rs b/examples/autonat/src/bin/autonat_client.rs index ff3e0805463..bc0c0521af8 100644 --- a/examples/autonat/src/bin/autonat_client.rs +++ b/examples/autonat/src/bin/autonat_client.rs @@ -65,7 +65,7 @@ async fn main() -> Result<(), Box> { let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); let behaviour = Behaviour::new(local_key.public()); diff --git a/examples/autonat/src/bin/autonat_server.rs b/examples/autonat/src/bin/autonat_server.rs index b6c51ba8b5e..7177a5bf840 100644 --- a/examples/autonat/src/bin/autonat_server.rs +++ b/examples/autonat/src/bin/autonat_server.rs @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box> { let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); let behaviour = Behaviour::new(local_key.public()); diff --git a/examples/chat-example/src/main.rs b/examples/chat-example/src/main.rs index 0d1c68a9d3b..2c038724c37 100644 --- a/examples/chat-example/src/main.rs +++ b/examples/chat-example/src/main.rs @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box> { let tcp_transport = tcp::async_io::Transport::new(tcp::Config::default().nodelay(true)) .upgrade(upgrade::Version::V1Lazy) .authenticate(noise::Config::new(&id_keys).expect("signing libp2p-noise static keypair")) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .timeout(std::time::Duration::from_secs(20)) .boxed(); let quic_transport = quic::async_std::Transport::new(quic::Config::new(&id_keys)); diff --git a/examples/dcutr/src/main.rs b/examples/dcutr/src/main.rs index 62e28ca9c57..4dbee86fac3 100644 --- a/examples/dcutr/src/main.rs +++ b/examples/dcutr/src/main.rs @@ -100,7 +100,7 @@ fn main() -> Result<(), Box> { .authenticate( noise::Config::new(&local_key).expect("Signing libp2p-noise static DH keypair failed."), ) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); #[derive(NetworkBehaviour)] diff --git a/examples/distributed-key-value-store/src/main.rs b/examples/distributed-key-value-store/src/main.rs index 83adfa6b43c..952e55ba6e7 100644 --- a/examples/distributed-key-value-store/src/main.rs +++ b/examples/distributed-key-value-store/src/main.rs @@ -66,7 +66,7 @@ async fn main() -> Result<(), Box> { let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); // We create a custom network behaviour that combines Kademlia and mDNS. diff --git a/examples/file-sharing/src/network.rs b/examples/file-sharing/src/network.rs index 5eedd22d765..64fad09774e 100644 --- a/examples/file-sharing/src/network.rs +++ b/examples/file-sharing/src/network.rs @@ -50,7 +50,7 @@ pub(crate) async fn new( let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&id_keys)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); // Build the Swarm, connecting the lower layer transport logic with the diff --git a/examples/identify/src/main.rs b/examples/identify/src/main.rs index 1b900043108..a46fac7f368 100644 --- a/examples/identify/src/main.rs +++ b/examples/identify/src/main.rs @@ -54,7 +54,7 @@ async fn main() -> Result<(), Box> { let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); // Create a identify network behaviour. diff --git a/examples/ipfs-private/src/main.rs b/examples/ipfs-private/src/main.rs index 1af5bebb4b6..fd18581407b 100644 --- a/examples/ipfs-private/src/main.rs +++ b/examples/ipfs-private/src/main.rs @@ -41,9 +41,7 @@ use libp2p::{ noise, ping, pnet::{PnetConfig, PreSharedKey}, swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}, - tcp, - yamux::YamuxConfig, - Multiaddr, PeerId, Transport, + tcp, yamux, Multiaddr, PeerId, Transport, }; use std::{env, error::Error, fs, path::Path, str::FromStr, time::Duration}; @@ -53,7 +51,7 @@ pub fn build_transport( psk: Option, ) -> transport::Boxed<(PeerId, StreamMuxerBox)> { let noise_config = noise::Config::new(&key_pair).unwrap(); - let yamux_config = YamuxConfig::default(); + let yamux_config = yamux::Config::default(); let base_transport = tcp::async_io::Transport::new(tcp::Config::default().nodelay(true)); let maybe_encrypted = match psk { diff --git a/examples/metrics/src/main.rs b/examples/metrics/src/main.rs index 7bbb533299c..2178de9802b 100644 --- a/examples/metrics/src/main.rs +++ b/examples/metrics/src/main.rs @@ -75,7 +75,7 @@ fn main() -> Result<(), Box> { tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(), Behaviour::new(local_pub_key), local_peer_id, diff --git a/examples/ping-example/src/main.rs b/examples/ping-example/src/main.rs index 34113e1d50d..ab67a8d2ba6 100644 --- a/examples/ping-example/src/main.rs +++ b/examples/ping-example/src/main.rs @@ -58,7 +58,7 @@ async fn main() -> Result<(), Box> { let transport = tcp::async_io::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&local_key)?) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); let mut swarm = diff --git a/examples/relay-server/src/main.rs b/examples/relay-server/src/main.rs index 1a6088b5563..416d4e7c111 100644 --- a/examples/relay-server/src/main.rs +++ b/examples/relay-server/src/main.rs @@ -53,7 +53,7 @@ fn main() -> Result<(), Box> { .authenticate( noise::Config::new(&local_key).expect("Signing libp2p-noise static DH keypair failed."), ) - .multiplex(libp2p::yamux::YamuxConfig::default()) + .multiplex(libp2p::yamux::Config::default()) .boxed(); let behaviour = Behaviour { diff --git a/examples/rendezvous/src/bin/rzv-discover.rs b/examples/rendezvous/src/bin/rzv-discover.rs index b1ac6d7220e..bd551c68f5a 100644 --- a/examples/rendezvous/src/bin/rzv-discover.rs +++ b/examples/rendezvous/src/bin/rzv-discover.rs @@ -45,7 +45,7 @@ async fn main() { tcp::tokio::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&key_pair).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(), MyBehaviour { rendezvous: rendezvous::client::Behaviour::new(key_pair.clone()), diff --git a/examples/rendezvous/src/bin/rzv-identify.rs b/examples/rendezvous/src/bin/rzv-identify.rs index 7cd28f73441..b970fc01a6e 100644 --- a/examples/rendezvous/src/bin/rzv-identify.rs +++ b/examples/rendezvous/src/bin/rzv-identify.rs @@ -41,7 +41,7 @@ async fn main() { tcp::tokio::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&key_pair).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(), MyBehaviour { identify: identify::Behaviour::new(identify::Config::new( diff --git a/examples/rendezvous/src/bin/rzv-register.rs b/examples/rendezvous/src/bin/rzv-register.rs index 7edd7dc1fdb..40053aa96b9 100644 --- a/examples/rendezvous/src/bin/rzv-register.rs +++ b/examples/rendezvous/src/bin/rzv-register.rs @@ -41,7 +41,7 @@ async fn main() { tcp::tokio::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&key_pair).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(), MyBehaviour { rendezvous: rendezvous::client::Behaviour::new(key_pair.clone()), diff --git a/examples/rendezvous/src/main.rs b/examples/rendezvous/src/main.rs index 929cdc097e2..7d6e5ad44a4 100644 --- a/examples/rendezvous/src/main.rs +++ b/examples/rendezvous/src/main.rs @@ -55,7 +55,7 @@ async fn main() { tcp::tokio::Transport::default() .upgrade(Version::V1Lazy) .authenticate(noise::Config::new(&key_pair).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(), MyBehaviour { identify: identify::Behaviour::new(identify::Config::new( diff --git a/interop-tests/src/bin/ping.rs b/interop-tests/src/bin/ping.rs index 7aacfa82a99..042be8b3eb8 100644 --- a/interop-tests/src/bin/ping.rs +++ b/interop-tests/src/bin/ping.rs @@ -181,9 +181,9 @@ async fn main() -> Result<()> { Ok(()) } -fn muxer_protocol_from_env() -> Result> { +fn muxer_protocol_from_env() -> Result> { Ok(match from_env("muxer")? { - Muxer::Yamux => Either::Left(yamux::YamuxConfig::default()), + Muxer::Yamux => Either::Left(yamux::Config::default()), Muxer::Mplex => Either::Right(mplex::MplexConfig::new()), }) } diff --git a/libp2p/Cargo.toml b/libp2p/Cargo.toml index dcdbb00f79d..f979366b71a 100644 --- a/libp2p/Cargo.toml +++ b/libp2p/Cargo.toml @@ -116,7 +116,7 @@ libp2p-rendezvous = { version = "0.12.0", path = "../protocols/rendezvous", opti libp2p-request-response = { version = "0.24.0", path = "../protocols/request-response", optional = true } libp2p-swarm = { version = "0.42.0", path = "../swarm" } libp2p-wasm-ext = { version = "0.39.0", path = "../transports/wasm-ext", optional = true } -libp2p-yamux = { version = "0.43.0", path = "../muxers/yamux", optional = true } +libp2p-yamux = { version = "0.43.1", path = "../muxers/yamux", optional = true } multiaddr = { version = "0.17.0" } pin-project = "1.0.0" diff --git a/libp2p/src/lib.rs b/libp2p/src/lib.rs index f2764e88ef9..fad08b0128c 100644 --- a/libp2p/src/lib.rs +++ b/libp2p/src/lib.rs @@ -233,7 +233,7 @@ pub async fn development_transport( .upgrade(core::upgrade::Version::V1) .authenticate(noise::Config::new(&keypair).unwrap()) .multiplex(core::upgrade::SelectUpgrade::new( - yamux::YamuxConfig::default(), + yamux::Config::default(), #[allow(deprecated)] mplex::MplexConfig::default(), )) @@ -290,7 +290,7 @@ pub fn tokio_development_transport( .upgrade(core::upgrade::Version::V1) .authenticate(noise::Config::new(&keypair).unwrap()) .multiplex(core::upgrade::SelectUpgrade::new( - yamux::YamuxConfig::default(), + yamux::Config::default(), #[allow(deprecated)] mplex::MplexConfig::default(), )) diff --git a/muxers/yamux/CHANGELOG.md b/muxers/yamux/CHANGELOG.md index 76a848c6302..6cd334b46a0 100644 --- a/muxers/yamux/CHANGELOG.md +++ b/muxers/yamux/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.43.1 - unreleased + +- Drop `Yamux` prefix from all types. + Users are encouraged to import the `yamux` module and refer to types via `yamux::Muxer`, `yamux::Config` etc. + See [PR XXXX]. + +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX + ## 0.43.0 - Update to `libp2p-core` `v0.39.0`. diff --git a/muxers/yamux/Cargo.toml b/muxers/yamux/Cargo.toml index b820fbd5998..53004065ec7 100644 --- a/muxers/yamux/Cargo.toml +++ b/muxers/yamux/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-yamux" edition = "2021" rust-version = "1.60.0" description = "Yamux multiplexing protocol for libp2p" -version = "0.43.0" +version = "0.43.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/muxers/yamux/src/lib.rs b/muxers/yamux/src/lib.rs index 42fb1621e56..197fefb69c7 100644 --- a/muxers/yamux/src/lib.rs +++ b/muxers/yamux/src/lib.rs @@ -40,8 +40,11 @@ use std::{ use thiserror::Error; use yamux::ConnectionError; +#[deprecated(note = "Import the `yamux` module instead and refer to this type as `yamux::Muxer`.")] +pub type Yamux = Muxer; + /// A Yamux connection. -pub struct Yamux { +pub struct Muxer { /// The [`futures::stream::Stream`] of incoming substreams. incoming: S, /// Handle to control the connection. @@ -62,13 +65,13 @@ pub struct Yamux { const MAX_BUFFERED_INBOUND_STREAMS: usize = 25; -impl fmt::Debug for Yamux { +impl fmt::Debug for Muxer { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("Yamux") } } -impl Yamux> +impl Muxer> where C: AsyncRead + AsyncWrite + Send + Unpin + 'static, { @@ -77,7 +80,7 @@ where let conn = yamux::Connection::new(io, cfg, mode); let ctrl = conn.control(); - Yamux { + Self { incoming: Incoming { stream: yamux::into_stream(conn).err_into().boxed(), _marker: std::marker::PhantomData, @@ -89,7 +92,7 @@ where } } -impl Yamux> +impl Muxer> where C: AsyncRead + AsyncWrite + Unpin + 'static, { @@ -98,7 +101,7 @@ where let conn = yamux::Connection::new(io, cfg, mode); let ctrl = conn.control(); - Yamux { + Self { incoming: LocalIncoming { stream: yamux::into_stream(conn).err_into().boxed_local(), _marker: std::marker::PhantomData, @@ -110,14 +113,15 @@ where } } -pub type YamuxResult = Result; +#[deprecated(note = "Use `Result` instead.")] +pub type YamuxResult = Result; -impl StreamMuxer for Yamux +impl StreamMuxer for Muxer where - S: Stream> + Unpin, + S: Stream> + Unpin, { type Substream = yamux::Stream; - type Error = YamuxError; + type Error = Error; fn poll_inbound( mut self: Pin<&mut Self>, @@ -138,7 +142,7 @@ where ) -> Poll> { Pin::new(&mut self.control) .poll_open_stream(cx) - .map_err(YamuxError) + .map_err(Error) } fn poll( @@ -165,11 +169,8 @@ where Poll::Pending } - fn poll_close(mut self: Pin<&mut Self>, c: &mut Context<'_>) -> Poll> { - if let Poll::Ready(()) = Pin::new(&mut self.control) - .poll_close(c) - .map_err(YamuxError)? - { + fn poll_close(mut self: Pin<&mut Self>, c: &mut Context<'_>) -> Poll> { + if let Poll::Ready(()) = Pin::new(&mut self.control).poll_close(c).map_err(Error)? { return Poll::Ready(Ok(())); } @@ -184,24 +185,27 @@ where } } -impl Yamux +impl Muxer where - S: Stream> + Unpin, + S: Stream> + Unpin, { - fn poll_inner(&mut self, cx: &mut Context<'_>) -> Poll> { + fn poll_inner(&mut self, cx: &mut Context<'_>) -> Poll> { self.incoming.poll_next_unpin(cx).map(|maybe_stream| { let stream = maybe_stream .transpose()? - .ok_or(YamuxError(ConnectionError::Closed))?; + .ok_or(Error(ConnectionError::Closed))?; Ok(stream) }) } } +#[deprecated(note = "Import the `yamux` module and refer to this type as `yamux::Config` instead.")] +pub type YamuxConfig = Config; + /// The yamux configuration. #[derive(Debug, Clone)] -pub struct YamuxConfig { +pub struct Config { inner: yamux::Config, mode: Option, } @@ -246,11 +250,16 @@ impl WindowUpdateMode { } } +#[deprecated( + note = "Import the `yamux` module and refer to this type as `yamux::LocalConfig` instead." +)] +pub type YamuxLocalConfig = LocalConfig; + /// The yamux configuration for upgrading I/O resources which are ![`Send`]. #[derive(Clone)] -pub struct YamuxLocalConfig(YamuxConfig); +pub struct LocalConfig(Config); -impl YamuxConfig { +impl Config { /// Creates a new `YamuxConfig` in client mode, regardless of whether /// it will be used for an inbound or outbound upgrade. pub fn client() -> Self { @@ -294,24 +303,24 @@ impl YamuxConfig { self } - /// Converts the config into a [`YamuxLocalConfig`] for use with upgrades + /// Converts the config into a [`LocalConfig`] for use with upgrades /// of I/O streams that are ![`Send`]. - pub fn into_local(self) -> YamuxLocalConfig { - YamuxLocalConfig(self) + pub fn into_local(self) -> LocalConfig { + LocalConfig(self) } } -impl Default for YamuxConfig { +impl Default for Config { fn default() -> Self { let mut inner = yamux::Config::default(); // For conformity with mplex, read-after-close on a multiplexed // connection is never permitted and not configurable. inner.set_read_after_close(false); - YamuxConfig { inner, mode: None } + Config { inner, mode: None } } } -impl UpgradeInfo for YamuxConfig { +impl UpgradeInfo for Config { type Info = &'static [u8]; type InfoIter = iter::Once; @@ -320,7 +329,7 @@ impl UpgradeInfo for YamuxConfig { } } -impl UpgradeInfo for YamuxLocalConfig { +impl UpgradeInfo for LocalConfig { type Info = &'static [u8]; type InfoIter = iter::Once; @@ -329,71 +338,74 @@ impl UpgradeInfo for YamuxLocalConfig { } } -impl InboundUpgrade for YamuxConfig +impl InboundUpgrade for Config where C: AsyncRead + AsyncWrite + Send + Unpin + 'static, { - type Output = Yamux>; + type Output = Muxer>; type Error = io::Error; type Future = future::Ready>; fn upgrade_inbound(self, io: C, _: Self::Info) -> Self::Future { let mode = self.mode.unwrap_or(yamux::Mode::Server); - future::ready(Ok(Yamux::new(io, self.inner, mode))) + future::ready(Ok(Muxer::new(io, self.inner, mode))) } } -impl InboundUpgrade for YamuxLocalConfig +impl InboundUpgrade for LocalConfig where C: AsyncRead + AsyncWrite + Unpin + 'static, { - type Output = Yamux>; + type Output = Muxer>; type Error = io::Error; type Future = future::Ready>; fn upgrade_inbound(self, io: C, _: Self::Info) -> Self::Future { let cfg = self.0; let mode = cfg.mode.unwrap_or(yamux::Mode::Server); - future::ready(Ok(Yamux::local(io, cfg.inner, mode))) + future::ready(Ok(Muxer::local(io, cfg.inner, mode))) } } -impl OutboundUpgrade for YamuxConfig +impl OutboundUpgrade for Config where C: AsyncRead + AsyncWrite + Send + Unpin + 'static, { - type Output = Yamux>; + type Output = Muxer>; type Error = io::Error; type Future = future::Ready>; fn upgrade_outbound(self, io: C, _: Self::Info) -> Self::Future { let mode = self.mode.unwrap_or(yamux::Mode::Client); - future::ready(Ok(Yamux::new(io, self.inner, mode))) + future::ready(Ok(Muxer::new(io, self.inner, mode))) } } -impl OutboundUpgrade for YamuxLocalConfig +impl OutboundUpgrade for LocalConfig where C: AsyncRead + AsyncWrite + Unpin + 'static, { - type Output = Yamux>; + type Output = Muxer>; type Error = io::Error; type Future = future::Ready>; fn upgrade_outbound(self, io: C, _: Self::Info) -> Self::Future { let cfg = self.0; let mode = cfg.mode.unwrap_or(yamux::Mode::Client); - future::ready(Ok(Yamux::local(io, cfg.inner, mode))) + future::ready(Ok(Muxer::local(io, cfg.inner, mode))) } } +#[deprecated(note = "Import the `yamux` module and refer to this type as `yamux::Error` instead.")] +pub type YamuxError = Error; + /// The Yamux [`StreamMuxer`] error type. #[derive(Debug, Error)] #[error("yamux error: {0}")] -pub struct YamuxError(#[from] yamux::ConnectionError); +pub struct Error(#[from] yamux::ConnectionError); -impl From for io::Error { - fn from(err: YamuxError) -> Self { +impl From for io::Error { + fn from(err: Error) -> Self { match err.0 { yamux::ConnectionError::Io(e) => e, e => io::Error::new(io::ErrorKind::Other, e), @@ -403,7 +415,7 @@ impl From for io::Error { /// The [`futures::stream::Stream`] of incoming substreams. pub struct Incoming { - stream: BoxStream<'static, Result>, + stream: BoxStream<'static, Result>, _marker: std::marker::PhantomData, } @@ -415,7 +427,7 @@ impl fmt::Debug for Incoming { /// The [`futures::stream::Stream`] of incoming substreams (`!Send`). pub struct LocalIncoming { - stream: LocalBoxStream<'static, Result>, + stream: LocalBoxStream<'static, Result>, _marker: std::marker::PhantomData, } @@ -426,7 +438,7 @@ impl fmt::Debug for LocalIncoming { } impl Stream for Incoming { - type Item = Result; + type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.stream.as_mut().poll_next_unpin(cx) @@ -440,7 +452,7 @@ impl Stream for Incoming { impl Unpin for Incoming {} impl Stream for LocalIncoming { - type Item = Result; + type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { self.stream.as_mut().poll_next_unpin(cx) diff --git a/muxers/yamux/tests/compliance.rs b/muxers/yamux/tests/compliance.rs index ba5161dde0d..14d69952b0e 100644 --- a/muxers/yamux/tests/compliance.rs +++ b/muxers/yamux/tests/compliance.rs @@ -1,10 +1,9 @@ -use libp2p_yamux::YamuxConfig; +use libp2p_yamux::Config; #[async_std::test] async fn close_implies_flush() { let (alice, bob) = - libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::() - .await; + libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::().await; libp2p_muxer_test_harness::close_implies_flush(alice, bob).await; } @@ -12,8 +11,7 @@ async fn close_implies_flush() { #[async_std::test] async fn read_after_close() { let (alice, bob) = - libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::() - .await; + libp2p_muxer_test_harness::connected_muxers_on_memory_ring_buffer::().await; libp2p_muxer_test_harness::read_after_close(alice, bob).await; } diff --git a/protocols/dcutr/tests/lib.rs b/protocols/dcutr/tests/lib.rs index cf725f75797..ba190782b12 100644 --- a/protocols/dcutr/tests/lib.rs +++ b/protocols/dcutr/tests/lib.rs @@ -121,7 +121,7 @@ fn build_client() -> Swarm { .or_transport(libp2p_tcp::async_io::Transport::default()) .upgrade(Version::V1) .authenticate(PlainText2Config { local_public_key }) - .multiplex(libp2p_yamux::YamuxConfig::default()) + .multiplex(libp2p_yamux::Config::default()) .boxed(); SwarmBuilder::without_executor( diff --git a/protocols/kad/src/behaviour/test.rs b/protocols/kad/src/behaviour/test.rs index f361a31f756..3f03842aff5 100644 --- a/protocols/kad/src/behaviour/test.rs +++ b/protocols/kad/src/behaviour/test.rs @@ -60,7 +60,7 @@ fn build_node_with_config(cfg: KademliaConfig) -> (Multiaddr, TestSwarm) { let transport = MemoryTransport::default() .upgrade(upgrade::Version::V1) .authenticate(noise::Config::new(&local_key).unwrap()) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); let local_id = local_public_key.to_peer_id(); diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index c11b865a8e0..4609b076220 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -24,7 +24,7 @@ libp2p-noise = { version = "0.42.2", path = "../../transports/noise" } libp2p-quic = { version = "0.7.0-alpha.2", path = "../../transports/quic", features = ["async-std"] } libp2p-swarm = { version = "0.42.1", path = "../../swarm", features = ["macros", "async-std"] } libp2p-tcp = { version = "0.39.0", path = "../../transports/tcp", features = ["async-io"] } -libp2p-yamux = { version = "0.43.0", path = "../../muxers/yamux" } +libp2p-yamux = { version = "0.43.1", path = "../../muxers/yamux" } log = "0.4" thiserror = "1.0" void = "1" diff --git a/protocols/perf/src/bin/perf-client.rs b/protocols/perf/src/bin/perf-client.rs index a1d809ac1cb..ddf3708ef5c 100644 --- a/protocols/perf/src/bin/perf-client.rs +++ b/protocols/perf/src/bin/perf-client.rs @@ -55,7 +55,7 @@ async fn main() -> Result<()> { libp2p_noise::Config::new(&local_key) .expect("Signing libp2p-noise static DH keypair failed."), ) - .multiplex(libp2p_yamux::YamuxConfig::default()); + .multiplex(libp2p_yamux::Config::default()); let quic = { let mut config = libp2p_quic::Config::new(&local_key); diff --git a/protocols/perf/src/bin/perf-server.rs b/protocols/perf/src/bin/perf-server.rs index 8499ccc602b..9219ed85723 100644 --- a/protocols/perf/src/bin/perf-server.rs +++ b/protocols/perf/src/bin/perf-server.rs @@ -49,7 +49,7 @@ async fn main() { libp2p_noise::Config::new(&local_key) .expect("Signing libp2p-noise static DH keypair failed."), ) - .multiplex(libp2p_yamux::YamuxConfig::default()); + .multiplex(libp2p_yamux::Config::default()); let quic = { let mut config = libp2p_quic::Config::new(&local_key); diff --git a/protocols/relay/tests/lib.rs b/protocols/relay/tests/lib.rs index 92538549ba1..2103893ba12 100644 --- a/protocols/relay/tests/lib.rs +++ b/protocols/relay/tests/lib.rs @@ -357,7 +357,7 @@ where transport .upgrade(upgrade::Version::V1) .authenticate(PlainText2Config { local_public_key }) - .multiplex(libp2p_yamux::YamuxConfig::default()) + .multiplex(libp2p_yamux::Config::default()) .boxed() } diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index ff26f228e0e..9c922a1c2ed 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -18,7 +18,7 @@ libp2p-identity = { version = "0.1.1", path = "../identity" } libp2p-plaintext = { version = "0.39.1", path = "../transports/plaintext" } libp2p-swarm = { version = "0.42.0", path = "../swarm" } libp2p-tcp = { version = "0.39.0", path = "../transports/tcp", features = ["async-io"] } -libp2p-yamux = { version = "0.43.0", path = "../muxers/yamux" } +libp2p-yamux = { version = "0.43.1", path = "../muxers/yamux" } futures = "0.3.28" log = "0.4.17" rand = "0.8.5" diff --git a/swarm-test/src/lib.rs b/swarm-test/src/lib.rs index 94bad497e8f..f93a1efcfe8 100644 --- a/swarm-test/src/lib.rs +++ b/swarm-test/src/lib.rs @@ -32,7 +32,7 @@ use libp2p_swarm::{ dial_opts::DialOpts, AddressScore, NetworkBehaviour, Swarm, SwarmBuilder, SwarmEvent, THandlerErr, }; -use libp2p_yamux::YamuxConfig; +use libp2p_yamux as yamux; use std::fmt::Debug; use std::time::Duration; @@ -216,7 +216,7 @@ where .authenticate(PlainText2Config { local_public_key: identity.public(), }) - .multiplex(YamuxConfig::default()) + .multiplex(yamux::Config::default()) .timeout(Duration::from_secs(20)) .boxed(); diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 3fba83cd44d..4ac5a59c089 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -2067,7 +2067,7 @@ mod tests { .authenticate(plaintext::PlainText2Config { local_public_key: local_public_key.clone(), }) - .multiplex(yamux::YamuxConfig::default()) + .multiplex(yamux::Config::default()) .boxed(); let behaviour = CallTraceBehaviour::new(MockBehaviour::new(handler_proto)); match ThreadPool::new().ok() { diff --git a/transports/pnet/tests/smoke.rs b/transports/pnet/tests/smoke.rs index 66fa01b7222..a7635c00ca3 100644 --- a/transports/pnet/tests/smoke.rs +++ b/transports/pnet/tests/smoke.rs @@ -111,7 +111,7 @@ where .and_then(move |socket, _| pnet.handshake(socket)) .upgrade(Version::V1) .authenticate(libp2p_noise::Config::new(&identity).unwrap()) - .multiplex(libp2p_yamux::YamuxConfig::default()) + .multiplex(libp2p_yamux::Config::default()) .boxed(); SwarmBuilder::with_tokio_executor( transport, diff --git a/transports/quic/tests/smoke.rs b/transports/quic/tests/smoke.rs index 0fe6a65c081..a576d3c9ef5 100644 --- a/transports/quic/tests/smoke.rs +++ b/transports/quic/tests/smoke.rs @@ -234,7 +234,7 @@ fn new_tcp_quic_transport() -> (PeerId, Boxed<(PeerId, StreamMuxerBox)>) { let tcp_transport = tcp::async_io::Transport::new(tcp::Config::default()) .upgrade(upgrade::Version::V1) .authenticate(noise::Config::new(&keypair).unwrap()) - .multiplex(yamux::YamuxConfig::default()); + .multiplex(yamux::Config::default()); let transport = OrTransport::new(quic_transport, tcp_transport) .map(|either_output, _| match either_output { diff --git a/transports/tls/tests/smoke.rs b/transports/tls/tests/smoke.rs index 9db82f0a693..17aa959c4b2 100644 --- a/transports/tls/tests/smoke.rs +++ b/transports/tls/tests/smoke.rs @@ -61,7 +61,7 @@ fn make_swarm() -> Swarm { let transport = MemoryTransport::default() .upgrade(Version::V1) .authenticate(libp2p_tls::Config::new(&identity).unwrap()) - .multiplex(libp2p_yamux::YamuxConfig::default()) + .multiplex(libp2p_yamux::Config::default()) .boxed(); SwarmBuilder::without_executor(