From 801473df2feeacb9d9153f69ccda4bf5b3d52883 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 2 Dec 2022 16:30:56 +0100 Subject: [PATCH 1/3] fix!: Remove simple::SimpleProtocol Due to lack of usage, remove the `simple::SimpleProtocol`. Users may look at `libp2p::core::upgrade` for alternatives. --- CHANGELOG.md | 4 +++ Cargo.toml | 2 +- src/lib.rs | 2 -- src/simple.rs | 96 --------------------------------------------------- 4 files changed, 5 insertions(+), 99 deletions(-) delete mode 100644 src/simple.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 966b2da7d0d..d654a05272b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,10 @@ # `libp2p` facade crate +# 0.51.0 + +- Remove `SimpleProtocol` due to being unused. See `libp2p::core::upgrade` for alternatives. + # 0.50.0 This is a large release. After > 4 years, rust-libp2p ships with an [(alpha) QUIC diff --git a/Cargo.toml b/Cargo.toml index 22011f7d382..6794e95f1e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p" edition = "2021" rust-version = "1.62.0" description = "Peer-to-peer networking library" -version = "0.50.0" +version = "0.51.0" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/src/lib.rs b/src/lib.rs index 1d80de1bd89..e87a5f746da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,7 +140,6 @@ pub use libp2p_yamux as yamux; mod transport_ext; pub mod bandwidth; -pub mod simple; #[cfg(doc)] pub mod tutorials; @@ -152,7 +151,6 @@ pub use self::core::{ PeerId, Transport, }; pub use self::multiaddr::{multiaddr as build_multiaddr, Multiaddr}; -pub use self::simple::SimpleProtocol; pub use self::swarm::Swarm; pub use self::transport_ext::TransportExt; diff --git a/src/simple.rs b/src/simple.rs deleted file mode 100644 index fb4d3b735d2..00000000000 --- a/src/simple.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2017 Parity Technologies (UK) Ltd. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -use crate::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; -use bytes::Bytes; -use futures::prelude::*; -use std::{iter, sync::Arc}; - -/// Implementation of `ConnectionUpgrade`. Convenient to use with small protocols. -#[derive(Debug)] -pub struct SimpleProtocol { - info: Bytes, - // Note: we put the closure `F` in an `Arc` because Rust closures aren't automatically clonable - // yet. - upgrade: Arc, -} - -impl SimpleProtocol { - /// Builds a `SimpleProtocol`. - pub fn new(info: N, upgrade: F) -> SimpleProtocol - where - N: Into, - { - SimpleProtocol { - info: info.into(), - upgrade: Arc::new(upgrade), - } - } -} - -impl Clone for SimpleProtocol { - fn clone(&self) -> Self { - SimpleProtocol { - info: self.info.clone(), - upgrade: self.upgrade.clone(), - } - } -} - -impl UpgradeInfo for SimpleProtocol { - type Info = Bytes; - type InfoIter = iter::Once; - - fn protocol_info(&self) -> Self::InfoIter { - iter::once(self.info.clone()) - } -} - -impl InboundUpgrade for SimpleProtocol -where - C: AsyncRead + AsyncWrite, - F: Fn(C) -> O, - O: Future>, -{ - type Output = A; - type Error = E; - type Future = O; - - fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future { - let upgrade = &self.upgrade; - upgrade(socket) - } -} - -impl OutboundUpgrade for SimpleProtocol -where - C: AsyncRead + AsyncWrite, - F: Fn(C) -> O, - O: Future>, -{ - type Output = A; - type Error = E; - type Future = O; - - fn upgrade_outbound(self, socket: C, _: Self::Info) -> Self::Future { - let upgrade = &self.upgrade; - upgrade(socket) - } -} From 0ce9462074e8954adf4fcfc4634624312fa4f224 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 2 Dec 2022 16:54:54 +0100 Subject: [PATCH 2/3] CHANGELOG: Add pull request link --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d654a05272b..66fab17ff8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,9 +45,11 @@ # `libp2p` facade crate -# 0.51.0 +# 0.51.0 [unreleased] -- Remove `SimpleProtocol` due to being unused. See `libp2p::core::upgrade` for alternatives. +- Remove `SimpleProtocol` due to being unused. See `libp2p::core::upgrade` for alternatives. See [PR 3191]. + +[PR 3191]: https://github.com/libp2p/rust-libp2p/pull/3191 # 0.50.0 From 3e4f37291d7ad030fb7f8971c6af1751b4c405f3 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 6 Dec 2022 19:15:53 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Oliveira --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66fab17ff8a..8401a224e36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ # 0.51.0 [unreleased] -- Remove `SimpleProtocol` due to being unused. See `libp2p::core::upgrade` for alternatives. See [PR 3191]. +- Remove `SimpleProtocol` due to being unused. See [`libp2p::core::upgrade`](https://docs.rs/libp2p/0.50.0/libp2p/core/upgrade/index.html) for alternatives. See [PR 3191]. [PR 3191]: https://github.com/libp2p/rust-libp2p/pull/3191