mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 17:21:34 +00:00
Remove Negotiated from upgrade traits (#1388)
* Remove Negotiated from upgrade traits * Remove import
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::{prelude::*, ready};
|
||||
use libp2p_core::{Negotiated, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use std::{io, iter, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@ -48,11 +48,11 @@ impl<C> InboundUpgrade<C> for DeflateConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite,
|
||||
{
|
||||
type Output = DeflateOutput<Negotiated<C>>;
|
||||
type Output = DeflateOutput<C>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, r: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, r: C, _: Self::Info) -> Self::Future {
|
||||
future::ok(DeflateOutput::new(r, self.compression))
|
||||
}
|
||||
}
|
||||
@ -61,11 +61,11 @@ impl<C> OutboundUpgrade<C> for DeflateConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite,
|
||||
{
|
||||
type Output = DeflateOutput<Negotiated<C>>;
|
||||
type Output = DeflateOutput<C>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, w: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, w: C, _: Self::Info) -> Self::Future {
|
||||
future::ok(DeflateOutput::new(w, self.compression))
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ where
|
||||
type Error = FloodsubDecodeError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_inbound(self, mut socket: upgrade::Negotiated<TSocket>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, mut socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
Box::pin(async move {
|
||||
let packet = upgrade::read_one(&mut socket, 2048).await?;
|
||||
let mut rpc: rpc_proto::RPC = protobuf::parse_from_bytes(&packet)?;
|
||||
@ -171,7 +171,7 @@ where
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
#[inline]
|
||||
fn upgrade_outbound(self, mut socket: upgrade::Negotiated<TSocket>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, mut socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
Box::pin(async move {
|
||||
let bytes = self.into_bytes();
|
||||
upgrade::write_one(&mut socket, bytes).await?;
|
||||
|
@ -108,14 +108,14 @@ where
|
||||
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<TSubstream>>::Output
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<TSubstream>>>::Output
|
||||
) {
|
||||
self.events.push(IdentifyHandlerEvent::Identify(protocol))
|
||||
}
|
||||
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<TSubstream>>>::Output,
|
||||
_info: Self::OutboundOpenInfo,
|
||||
) {
|
||||
self.events.push(IdentifyHandlerEvent::Identified(protocol));
|
||||
|
@ -23,7 +23,7 @@ use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
Multiaddr,
|
||||
PublicKey,
|
||||
upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated}
|
||||
upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeInfo}
|
||||
};
|
||||
use log::{debug, trace};
|
||||
use protobuf::Message as ProtobufMessage;
|
||||
@ -125,11 +125,11 @@ impl<C> InboundUpgrade<C> for IdentifyProtocolConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
type Output = ReplySubstream<Negotiated<C>>;
|
||||
type Output = ReplySubstream<C>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, io::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
trace!("Upgrading inbound connection");
|
||||
future::ok(ReplySubstream { inner: socket })
|
||||
}
|
||||
@ -143,7 +143,7 @@ where
|
||||
type Error = upgrade::ReadOneError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_outbound(self, mut socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, mut socket: C, _: Self::Info) -> Self::Future {
|
||||
Box::pin(async move {
|
||||
socket.close().await?;
|
||||
let msg = upgrade::read_one(&mut socket, 4096).await?;
|
||||
|
@ -59,7 +59,7 @@ where
|
||||
next_connec_unique_id: UniqueConnecId,
|
||||
|
||||
/// List of active substreams with the state they are in.
|
||||
substreams: Vec<SubstreamState<Negotiated<TSubstream>, TUserData>>,
|
||||
substreams: Vec<SubstreamState<TSubstream, TUserData>>,
|
||||
|
||||
/// Until when to keep the connection alive.
|
||||
keep_alive: KeepAlive,
|
||||
@ -75,29 +75,29 @@ where
|
||||
OutPendingOpen(KadRequestMsg, Option<TUserData>),
|
||||
/// Waiting to send a message to the remote.
|
||||
OutPendingSend(
|
||||
KadOutStreamSink<TSubstream>,
|
||||
KadOutStreamSink<Negotiated<TSubstream>>,
|
||||
KadRequestMsg,
|
||||
Option<TUserData>,
|
||||
),
|
||||
/// Waiting to flush the substream so that the data arrives to the remote.
|
||||
OutPendingFlush(KadOutStreamSink<TSubstream>, Option<TUserData>),
|
||||
OutPendingFlush(KadOutStreamSink<Negotiated<TSubstream>>, Option<TUserData>),
|
||||
/// Waiting for an answer back from the remote.
|
||||
// TODO: add timeout
|
||||
OutWaitingAnswer(KadOutStreamSink<TSubstream>, TUserData),
|
||||
OutWaitingAnswer(KadOutStreamSink<Negotiated<TSubstream>>, TUserData),
|
||||
/// An error happened on the substream and we should report the error to the user.
|
||||
OutReportError(KademliaHandlerQueryErr, TUserData),
|
||||
/// The substream is being closed.
|
||||
OutClosing(KadOutStreamSink<TSubstream>),
|
||||
OutClosing(KadOutStreamSink<Negotiated<TSubstream>>),
|
||||
/// Waiting for a request from the remote.
|
||||
InWaitingMessage(UniqueConnecId, KadInStreamSink<TSubstream>),
|
||||
InWaitingMessage(UniqueConnecId, KadInStreamSink<Negotiated<TSubstream>>),
|
||||
/// Waiting for the user to send a `KademliaHandlerIn` event containing the response.
|
||||
InWaitingUser(UniqueConnecId, KadInStreamSink<TSubstream>),
|
||||
InWaitingUser(UniqueConnecId, KadInStreamSink<Negotiated<TSubstream>>),
|
||||
/// Waiting to send an answer back to the remote.
|
||||
InPendingSend(UniqueConnecId, KadInStreamSink<TSubstream>, KadResponseMsg),
|
||||
InPendingSend(UniqueConnecId, KadInStreamSink<Negotiated<TSubstream>>, KadResponseMsg),
|
||||
/// Waiting to flush an answer back to the remote.
|
||||
InPendingFlush(UniqueConnecId, KadInStreamSink<TSubstream>),
|
||||
InPendingFlush(UniqueConnecId, KadInStreamSink<Negotiated<TSubstream>>),
|
||||
/// The substream is being closed.
|
||||
InClosing(KadInStreamSink<TSubstream>),
|
||||
InClosing(KadInStreamSink<Negotiated<TSubstream>>),
|
||||
}
|
||||
|
||||
impl<TSubstream, TUserData> SubstreamState<TSubstream, TUserData>
|
||||
@ -450,7 +450,7 @@ where
|
||||
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<TSubstream>>>::Output,
|
||||
(msg, user_data): Self::OutboundOpenInfo,
|
||||
) {
|
||||
self.substreams
|
||||
@ -459,7 +459,7 @@ where
|
||||
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<TSubstream>>::Output,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<TSubstream>>>::Output,
|
||||
) {
|
||||
// If `self.allow_listening` is false, then we produced a `DeniedUpgrade` and `protocol`
|
||||
// is a `Void`.
|
||||
|
@ -37,7 +37,7 @@ use crate::record::{self, Record};
|
||||
use futures::prelude::*;
|
||||
use futures_codec::Framed;
|
||||
use libp2p_core::{Multiaddr, PeerId};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use protobuf::{self, Message};
|
||||
use std::{borrow::Cow, convert::TryFrom, time::Duration};
|
||||
use std::{io, iter};
|
||||
@ -175,11 +175,11 @@ impl<C> InboundUpgrade<C> for KademliaProtocolConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
type Output = KadInStreamSink<Negotiated<C>>;
|
||||
type Output = KadInStreamSink<C>;
|
||||
type Future = future::Ready<Result<Self::Output, io::Error>>;
|
||||
type Error = io::Error;
|
||||
|
||||
fn upgrade_inbound(self, incoming: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, incoming: C, _: Self::Info) -> Self::Future {
|
||||
let mut codec = UviBytes::default();
|
||||
codec.set_max_len(4096);
|
||||
|
||||
@ -207,11 +207,11 @@ impl<C> OutboundUpgrade<C> for KademliaProtocolConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
type Output = KadOutStreamSink<Negotiated<C>>;
|
||||
type Output = KadOutStreamSink<C>;
|
||||
type Future = future::Ready<Result<Self::Output, io::Error>>;
|
||||
type Error = io::Error;
|
||||
|
||||
fn upgrade_outbound(self, incoming: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, incoming: C, _: Self::Info) -> Self::Future {
|
||||
let mut codec = UviBytes::default();
|
||||
codec.set_max_len(4096);
|
||||
|
||||
|
@ -63,7 +63,7 @@ pub use protocol::{Keypair, AuthenticKeypair, KeypairIdentity, PublicKey, Secret
|
||||
pub use protocol::{Protocol, ProtocolParams, x25519::X25519, IX, IK, XX};
|
||||
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{identity, PeerId, UpgradeInfo, InboundUpgrade, OutboundUpgrade, Negotiated};
|
||||
use libp2p_core::{identity, PeerId, UpgradeInfo, InboundUpgrade, OutboundUpgrade};
|
||||
use std::pin::Pin;
|
||||
use zeroize::Zeroize;
|
||||
|
||||
@ -162,11 +162,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.build_responder()
|
||||
@ -183,11 +183,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.build_initiator()
|
||||
@ -206,11 +206,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.build_responder()
|
||||
@ -227,11 +227,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.build_initiator()
|
||||
@ -250,11 +250,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.build_responder()
|
||||
@ -271,11 +271,11 @@ where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (RemoteIdentity<C>, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Handshake<Negotiated<T>, C>;
|
||||
type Future = Handshake<T, C>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
let session = self.params.into_builder()
|
||||
.local_private_key(self.dh_keys.secret().as_ref())
|
||||
.remote_public_key(self.remote.0.as_ref())
|
||||
@ -319,18 +319,18 @@ where
|
||||
impl<T, P, C, R> InboundUpgrade<T> for NoiseAuthenticated<P, C, R>
|
||||
where
|
||||
NoiseConfig<P, C, R>: UpgradeInfo + InboundUpgrade<T,
|
||||
Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>),
|
||||
Output = (RemoteIdentity<C>, NoiseOutput<T>),
|
||||
Error = NoiseError
|
||||
> + 'static,
|
||||
<NoiseConfig<P, C, R> as InboundUpgrade<T>>::Future: Send,
|
||||
T: AsyncRead + AsyncWrite + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (PeerId, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (PeerId, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<T>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: T, info: Self::Info) -> Self::Future {
|
||||
Box::pin(self.config.upgrade_inbound(socket, info)
|
||||
.and_then(|(remote, io)| match remote {
|
||||
RemoteIdentity::IdentityKey(pk) => future::ok((pk.into_peer_id(), io)),
|
||||
@ -342,18 +342,18 @@ where
|
||||
impl<T, P, C, R> OutboundUpgrade<T> for NoiseAuthenticated<P, C, R>
|
||||
where
|
||||
NoiseConfig<P, C, R>: UpgradeInfo + OutboundUpgrade<T,
|
||||
Output = (RemoteIdentity<C>, NoiseOutput<Negotiated<T>>),
|
||||
Output = (RemoteIdentity<C>, NoiseOutput<T>),
|
||||
Error = NoiseError
|
||||
> + 'static,
|
||||
<NoiseConfig<P, C, R> as OutboundUpgrade<T>>::Future: Send,
|
||||
T: AsyncRead + AsyncWrite + Send + 'static,
|
||||
C: Protocol<C> + AsRef<[u8]> + Zeroize + Send + 'static,
|
||||
{
|
||||
type Output = (PeerId, NoiseOutput<Negotiated<T>>);
|
||||
type Output = (PeerId, NoiseOutput<T>);
|
||||
type Error = NoiseError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<T>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: T, info: Self::Info) -> Self::Future {
|
||||
Box::pin(self.config.upgrade_outbound(socket, info)
|
||||
.and_then(|(remote, io)| match remote {
|
||||
RemoteIdentity::IdentityKey(pk) => future::ok((pk.into_peer_id(), io)),
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use futures::{future::BoxFuture, prelude::*};
|
||||
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated};
|
||||
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use log::debug;
|
||||
use rand::{distributions, prelude::*};
|
||||
use std::{io, iter, time::Duration};
|
||||
@ -61,7 +61,7 @@ where
|
||||
type Error = io::Error;
|
||||
type Future = BoxFuture<'static, Result<(), io::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, mut socket: Negotiated<TSocket>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, mut socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
async move {
|
||||
let mut payload = [0u8; 32];
|
||||
socket.read_exact(&mut payload).await?;
|
||||
@ -80,7 +80,7 @@ where
|
||||
type Error = io::Error;
|
||||
type Future = BoxFuture<'static, Result<Duration, io::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, mut socket: Negotiated<TSocket>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, mut socket: TSocket, _: Self::Info) -> Self::Future {
|
||||
let payload: [u8; 32] = thread_rng().sample(distributions::Standard);
|
||||
debug!("Preparing ping payload {:?}", payload);
|
||||
async move {
|
||||
|
@ -31,7 +31,6 @@ use libp2p_core::{
|
||||
InboundUpgrade,
|
||||
OutboundUpgrade,
|
||||
UpgradeInfo,
|
||||
upgrade::Negotiated,
|
||||
PeerId,
|
||||
PublicKey,
|
||||
};
|
||||
@ -84,21 +83,21 @@ impl UpgradeInfo for PlainText1Config {
|
||||
}
|
||||
|
||||
impl<C> InboundUpgrade<C> for PlainText1Config {
|
||||
type Output = Negotiated<C>;
|
||||
type Output = C;
|
||||
type Error = Void;
|
||||
type Future = Ready<Result<Negotiated<C>, Self::Error>>;
|
||||
type Future = Ready<Result<C, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, i: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, i: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(i))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> OutboundUpgrade<C> for PlainText1Config {
|
||||
type Output = Negotiated<C>;
|
||||
type Output = C;
|
||||
type Error = Void;
|
||||
type Future = Ready<Result<Negotiated<C>, Self::Error>>;
|
||||
type Future = Ready<Result<C, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, i: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, i: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(i))
|
||||
}
|
||||
}
|
||||
@ -123,11 +122,11 @@ impl<C> InboundUpgrade<C> for PlainText2Config
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + Unpin + 'static
|
||||
{
|
||||
type Output = (PeerId, PlainTextOutput<Negotiated<C>>);
|
||||
type Output = (PeerId, PlainTextOutput<C>);
|
||||
type Error = PlainTextError;
|
||||
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
Box::pin(self.handshake(socket))
|
||||
}
|
||||
}
|
||||
@ -136,11 +135,11 @@ impl<C> OutboundUpgrade<C> for PlainText2Config
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + Unpin + 'static
|
||||
{
|
||||
type Output = (PeerId, PlainTextOutput<Negotiated<C>>);
|
||||
type Output = (PeerId, PlainTextOutput<C>);
|
||||
type Error = PlainTextError;
|
||||
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
Box::pin(self.handshake(socket))
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ pub use self::error::SecioError;
|
||||
|
||||
use futures::stream::MapErr as StreamMapErr;
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{PeerId, PublicKey, identity, upgrade::{UpgradeInfo, InboundUpgrade, OutboundUpgrade, Negotiated}};
|
||||
use libp2p_core::{PeerId, PublicKey, identity, upgrade::{UpgradeInfo, InboundUpgrade, OutboundUpgrade}};
|
||||
use log::debug;
|
||||
use rw_stream_sink::RwStreamSink;
|
||||
use std::{io, iter, pin::Pin, task::Context, task::Poll};
|
||||
@ -179,11 +179,11 @@ impl<T> InboundUpgrade<T> for SecioConfig
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static
|
||||
{
|
||||
type Output = (PeerId, SecioOutput<Negotiated<T>>);
|
||||
type Output = (PeerId, SecioOutput<T>);
|
||||
type Error = SecioError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
Box::pin(self.handshake(socket))
|
||||
}
|
||||
}
|
||||
@ -192,11 +192,11 @@ impl<T> OutboundUpgrade<T> for SecioConfig
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin + Send + 'static
|
||||
{
|
||||
type Output = (PeerId, SecioOutput<Negotiated<T>>);
|
||||
type Output = (PeerId, SecioOutput<T>);
|
||||
type Error = SecioError;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<T>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: T, _: Self::Info) -> Self::Future {
|
||||
Box::pin(self.handshake(socket))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user