From 5c785b92e73a6c21d52e6f9a560a0f619a33808f Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 15 May 2023 14:38:44 +0200 Subject: [PATCH] feat(plaintext): remove `Plaintext1Config` `Plaintext2Config` works with the upgrade infrastructure and is thus preferable. Related: #3915. Pull-Request: #3940. --- Cargo.lock | 1 - transports/plaintext/CHANGELOG.md | 5 +++ transports/plaintext/Cargo.toml | 1 - transports/plaintext/src/lib.rs | 60 ------------------------------- 4 files changed, 5 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0380178273..cdf3ed1e04a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2856,7 +2856,6 @@ dependencies = [ "quickcheck-ext", "rand 0.8.5", "unsigned-varint", - "void", ] [[package]] diff --git a/transports/plaintext/CHANGELOG.md b/transports/plaintext/CHANGELOG.md index 5f04ca16cba..be1791c17c3 100644 --- a/transports/plaintext/CHANGELOG.md +++ b/transports/plaintext/CHANGELOG.md @@ -3,7 +3,12 @@ - Raise MSRV to 1.65. See [PR 3715]. +- Remove `Plaintext1Config`. + Use `Plaintext2Config` instead. + See [PR 3915]. + [PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715 +[PR 3915]: https://github.com/libp2p/rust-libp2p/pull/3915 ## 0.39.1 diff --git a/transports/plaintext/Cargo.toml b/transports/plaintext/Cargo.toml index 6946f22558e..ba60454d675 100644 --- a/transports/plaintext/Cargo.toml +++ b/transports/plaintext/Cargo.toml @@ -19,7 +19,6 @@ libp2p-identity = { workspace = true } log = "0.4.8" quick-protobuf = "0.8" unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] } -void = "1.0.2" [dev-dependencies] env_logger = "0.10.0" diff --git a/transports/plaintext/src/lib.rs b/transports/plaintext/src/lib.rs index 64aea0b82a6..76e70a025b7 100644 --- a/transports/plaintext/src/lib.rs +++ b/transports/plaintext/src/lib.rs @@ -26,7 +26,6 @@ use crate::error::PlainTextError; use bytes::Bytes; use futures::future::BoxFuture; -use futures::future::{self, Ready}; use futures::prelude::*; use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p_identity as identity; @@ -38,7 +37,6 @@ use std::{ pin::Pin, task::{Context, Poll}, }; -use void::Void; mod error; mod handshake; @@ -48,64 +46,6 @@ mod proto { pub(crate) use self::structs::Exchange; } -/// `PlainText1Config` is an insecure connection handshake for testing purposes only. -/// -/// > **Note**: Given that `PlainText1Config` has no notion of exchanging peer identity information it is not compatible -/// > with the `libp2p_core::transport::upgrade::Builder` pattern. See -/// > [`PlainText2Config`](struct.PlainText2Config.html) if compatibility is needed. Even though not compatible with the -/// > Builder pattern one can still do an upgrade *manually*: -/// -/// ``` -/// # use libp2p_core::transport::{ Transport, memory::MemoryTransport }; -/// # use libp2p_plaintext::PlainText1Config; -/// # -/// MemoryTransport::default() -/// .and_then(move |io, endpoint| { -/// libp2p_core::upgrade::apply( -/// io, -/// PlainText1Config{}, -/// endpoint, -/// libp2p_core::transport::upgrade::Version::V1, -/// ) -/// }) -/// .map(|plaintext, _endpoint| { -/// unimplemented!(); -/// // let peer_id = somehow_derive_peer_id(); -/// // return (peer_id, plaintext); -/// }); -/// ``` -#[derive(Debug, Copy, Clone)] -pub struct PlainText1Config; - -impl UpgradeInfo for PlainText1Config { - type Info = &'static str; - type InfoIter = iter::Once; - - fn protocol_info(&self) -> Self::InfoIter { - iter::once("/plaintext/1.0.0") - } -} - -impl InboundUpgrade for PlainText1Config { - type Output = C; - type Error = Void; - type Future = Ready>; - - fn upgrade_inbound(self, i: C, _: Self::Info) -> Self::Future { - future::ready(Ok(i)) - } -} - -impl OutboundUpgrade for PlainText1Config { - type Output = C; - type Error = Void; - type Future = Ready>; - - fn upgrade_outbound(self, i: C, _: Self::Info) -> Self::Future { - future::ready(Ok(i)) - } -} - /// `PlainText2Config` is an insecure connection handshake for testing purposes only, implementing /// the libp2p plaintext connection handshake specification. #[derive(Clone)]