mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 01:21:21 +00:00
Remove Negotiated from upgrade traits (#1388)
* Remove Negotiated from upgrade traits * Remove import
This commit is contained in:
@ -25,6 +25,7 @@ pub use crate::upgrade::Version;
|
||||
use crate::{
|
||||
ConnectedPoint,
|
||||
ConnectionInfo,
|
||||
Negotiated,
|
||||
transport::{
|
||||
Transport,
|
||||
TransportError,
|
||||
@ -106,8 +107,8 @@ where
|
||||
I: ConnectionInfo,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
D: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C, Output = (I, D), Error = E>,
|
||||
U: OutboundUpgrade<C, Output = (I, D), Error = E> + Clone,
|
||||
U: InboundUpgrade<Negotiated<C>, Output = (I, D), Error = E>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = (I, D), Error = E> + Clone,
|
||||
E: Error + 'static,
|
||||
{
|
||||
let version = self.version;
|
||||
@ -138,8 +139,8 @@ where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
D: AsyncRead + AsyncWrite + Unpin,
|
||||
I: ConnectionInfo,
|
||||
U: InboundUpgrade<C, Output = D, Error = E>,
|
||||
U: OutboundUpgrade<C, Output = D, Error = E> + Clone,
|
||||
U: InboundUpgrade<Negotiated<C>, Output = D, Error = E>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = D, Error = E> + Clone,
|
||||
E: Error + 'static,
|
||||
{
|
||||
Builder::new(Upgrade::new(self.inner, upgrade), self.version)
|
||||
@ -166,8 +167,8 @@ where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
M: StreamMuxer,
|
||||
I: ConnectionInfo,
|
||||
U: InboundUpgrade<C, Output = M, Error = E>,
|
||||
U: OutboundUpgrade<C, Output = M, Error = E> + Clone,
|
||||
U: InboundUpgrade<Negotiated<C>, Output = M, Error = E>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = M, Error = E> + Clone,
|
||||
E: Error + 'static,
|
||||
{
|
||||
let version = self.version;
|
||||
@ -185,7 +186,7 @@ where
|
||||
pub struct Authenticate<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C> + OutboundUpgrade<C>
|
||||
U: InboundUpgrade<Negotiated<C>> + OutboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
inner: EitherUpgrade<C, U>
|
||||
}
|
||||
@ -193,9 +194,9 @@ where
|
||||
impl<C, U> Future for Authenticate<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C> + OutboundUpgrade<C,
|
||||
Output = <U as InboundUpgrade<C>>::Output,
|
||||
Error = <U as InboundUpgrade<C>>::Error
|
||||
U: InboundUpgrade<Negotiated<C>> + OutboundUpgrade<Negotiated<C>,
|
||||
Output = <U as InboundUpgrade<Negotiated<C>>>::Output,
|
||||
Error = <U as InboundUpgrade<Negotiated<C>>>::Error
|
||||
>
|
||||
{
|
||||
type Output = <EitherUpgrade<C, U> as Future>::Output;
|
||||
@ -212,7 +213,7 @@ where
|
||||
pub struct Multiplex<C, U, I>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C> + OutboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>> + OutboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
info: Option<I>,
|
||||
upgrade: EitherUpgrade<C, U>,
|
||||
@ -221,8 +222,8 @@ where
|
||||
impl<C, U, I, M, E> Future for Multiplex<C, U, I>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C, Output = M, Error = E>,
|
||||
U: OutboundUpgrade<C, Output = M, Error = E>
|
||||
U: InboundUpgrade<Negotiated<C>, Output = M, Error = E>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = M, Error = E>
|
||||
{
|
||||
type Output = Result<(I, M), UpgradeError<E>>;
|
||||
|
||||
@ -239,7 +240,7 @@ where
|
||||
impl<C, U, I> Unpin for Multiplex<C, U, I>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C> + OutboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>> + OutboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
}
|
||||
|
||||
@ -266,8 +267,8 @@ where
|
||||
T::ListenerUpgrade: Unpin,
|
||||
T::Error: 'static,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C, Output = D, Error = E>,
|
||||
U: OutboundUpgrade<C, Output = D, Error = E> + Clone,
|
||||
U: InboundUpgrade<Negotiated<C>, Output = D, Error = E>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = D, Error = E> + Clone,
|
||||
E: Error + 'static
|
||||
{
|
||||
type Output = (I, D);
|
||||
@ -333,7 +334,7 @@ where
|
||||
/// The [`Transport::Dial`] future of an [`Upgrade`]d transport.
|
||||
pub struct DialUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
U: OutboundUpgrade<C>,
|
||||
U: OutboundUpgrade<Negotiated<C>>,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
future: F,
|
||||
@ -344,7 +345,7 @@ impl<F, U, I, C, D> Future for DialUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
F: TryFuture<Ok = (I, C)> + Unpin,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C, Output = D>,
|
||||
U: OutboundUpgrade<Negotiated<C>, Output = D>,
|
||||
U::Error: Error
|
||||
{
|
||||
type Output = Result<(I, D), TransportUpgradeError<F::Error, U::Error>>;
|
||||
@ -379,7 +380,7 @@ where
|
||||
|
||||
impl<F, U, I, C> Unpin for DialUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
U: OutboundUpgrade<C>,
|
||||
U: OutboundUpgrade<Negotiated<C>>,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
}
|
||||
@ -395,7 +396,7 @@ where
|
||||
S: TryStream<Ok = ListenerEvent<F>> + Unpin,
|
||||
F: TryFuture<Ok = (I, C)>,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C, Output = D> + Clone
|
||||
U: InboundUpgrade<Negotiated<C>, Output = D> + Clone
|
||||
{
|
||||
type Item = Result<ListenerEvent<ListenerUpgradeFuture<F, U, I, C>>, TransportUpgradeError<S::Error, U::Error>>;
|
||||
|
||||
@ -425,7 +426,7 @@ impl<S, U> Unpin for ListenerStream<S, U> {
|
||||
pub struct ListenerUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>
|
||||
U: InboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
future: F,
|
||||
upgrade: future::Either<Option<U>, (Option<I>, InboundUpgradeApply<C, U>)>
|
||||
@ -435,7 +436,7 @@ impl<F, U, I, C, D> Future for ListenerUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
F: TryFuture<Ok = (I, C)> + Unpin,
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C, Output = D>,
|
||||
U: InboundUpgrade<Negotiated<C>, Output = D>,
|
||||
U::Error: Error
|
||||
{
|
||||
type Output = Result<(I, D), TransportUpgradeError<F::Error, U::Error>>;
|
||||
@ -471,6 +472,6 @@ where
|
||||
impl<F, U, I, C> Unpin for ListenerUpgradeFuture<F, U, I, C>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>
|
||||
U: InboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::ConnectedPoint;
|
||||
use crate::{ConnectedPoint, Negotiated};
|
||||
use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeError, ProtocolName};
|
||||
use futures::{future::Either, prelude::*, compat::Compat, compat::Compat01As03, compat::Future01CompatExt};
|
||||
use log::debug;
|
||||
@ -32,7 +32,7 @@ pub fn apply<C, U>(conn: C, up: U, cp: ConnectedPoint, v: Version)
|
||||
-> Either<InboundUpgradeApply<C, U>, OutboundUpgradeApply<C, U>>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C> + OutboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>> + OutboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
if cp.is_listener() {
|
||||
Either::Left(apply_inbound(conn, up))
|
||||
@ -45,7 +45,7 @@ where
|
||||
pub fn apply_inbound<C, U>(conn: C, up: U) -> InboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
let iter = up.protocol_info().into_iter().map(NameWrap as fn(_) -> NameWrap<_>);
|
||||
let future = multistream_select::listener_select_proto(Compat::new(conn), iter).compat();
|
||||
@ -58,7 +58,7 @@ where
|
||||
pub fn apply_outbound<C, U>(conn: C, up: U, v: Version) -> OutboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C>
|
||||
U: OutboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
let iter = up.protocol_info().into_iter().map(NameWrap as fn(_) -> NameWrap<_>);
|
||||
let future = multistream_select::dialer_select_proto(Compat::new(conn), iter, v).compat();
|
||||
@ -71,7 +71,7 @@ where
|
||||
pub struct InboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>
|
||||
U: InboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
inner: InboundUpgradeApplyState<C, U>
|
||||
}
|
||||
@ -79,7 +79,7 @@ where
|
||||
enum InboundUpgradeApplyState<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
Init {
|
||||
future: Compat01As03<ListenerSelectFuture<Compat<C>, NameWrap<U::Info>>>,
|
||||
@ -94,14 +94,14 @@ where
|
||||
impl<C, U> Unpin for InboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<C, U> Future for InboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: InboundUpgrade<C>,
|
||||
U: InboundUpgrade<Negotiated<C>>,
|
||||
U::Future: Unpin,
|
||||
{
|
||||
type Output = Result<U::Output, UpgradeError<U::Error>>;
|
||||
@ -148,7 +148,7 @@ where
|
||||
pub struct OutboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C>
|
||||
U: OutboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
inner: OutboundUpgradeApplyState<C, U>
|
||||
}
|
||||
@ -156,7 +156,7 @@ where
|
||||
enum OutboundUpgradeApplyState<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C>
|
||||
U: OutboundUpgrade<Negotiated<C>>
|
||||
{
|
||||
Init {
|
||||
future: Compat01As03<DialerSelectFuture<Compat<C>, NameWrapIter<<U::InfoIter as IntoIterator>::IntoIter>>>,
|
||||
@ -171,14 +171,14 @@ where
|
||||
impl<C, U> Unpin for OutboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C>,
|
||||
U: OutboundUpgrade<Negotiated<C>>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<C, U> Future for OutboundUpgradeApply<C, U>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
U: OutboundUpgrade<C>,
|
||||
U: OutboundUpgrade<Negotiated<C>>,
|
||||
U::Future: Unpin,
|
||||
{
|
||||
type Output = Result<U::Output, UpgradeError<U::Error>>;
|
||||
|
@ -18,7 +18,6 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::Negotiated;
|
||||
use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use futures::future;
|
||||
use std::iter;
|
||||
@ -43,7 +42,7 @@ impl<C> InboundUpgrade<C> for DeniedUpgrade {
|
||||
type Error = Void;
|
||||
type Future = future::Pending<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, _: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, _: C, _: Self::Info) -> Self::Future {
|
||||
future::pending()
|
||||
}
|
||||
}
|
||||
@ -53,7 +52,7 @@ impl<C> OutboundUpgrade<C> for DeniedUpgrade {
|
||||
type Error = Void;
|
||||
type Future = future::Pending<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, _: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, _: C, _: Self::Info) -> Self::Future {
|
||||
future::pending()
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::{
|
||||
Negotiated,
|
||||
either::{EitherOutput, EitherError, EitherFuture2, EitherName},
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}
|
||||
};
|
||||
@ -56,7 +55,7 @@ where
|
||||
type Error = EitherError<EA, EB>;
|
||||
type Future = EitherFuture2<A::Future, B::Future>;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
match (self, info) {
|
||||
(EitherUpgrade::A(a), EitherName::A(info)) => EitherFuture2::A(a.upgrade_inbound(sock, info)),
|
||||
(EitherUpgrade::B(b), EitherName::B(info)) => EitherFuture2::B(b.upgrade_inbound(sock, info)),
|
||||
@ -74,7 +73,7 @@ where
|
||||
type Error = EitherError<EA, EB>;
|
||||
type Future = EitherFuture2<A::Future, B::Future>;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
match (self, info) {
|
||||
(EitherUpgrade::A(a), EitherName::A(info)) => EitherFuture2::A(a.upgrade_outbound(sock, info)),
|
||||
(EitherUpgrade::B(b), EitherName::B(info)) => EitherFuture2::B(b.upgrade_outbound(sock, info)),
|
||||
|
@ -18,7 +18,6 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::Negotiated;
|
||||
use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use futures::prelude::*;
|
||||
use std::{pin::Pin, task::Context, task::Poll};
|
||||
@ -54,7 +53,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = MapFuture<U::Future, F>;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
MapFuture {
|
||||
inner: self.upgrade.upgrade_inbound(sock, info),
|
||||
map: Some(self.fun)
|
||||
@ -70,7 +69,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = U::Future;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
self.upgrade.upgrade_outbound(sock, info)
|
||||
}
|
||||
}
|
||||
@ -105,7 +104,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = U::Future;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
self.upgrade.upgrade_inbound(sock, info)
|
||||
}
|
||||
}
|
||||
@ -119,7 +118,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = MapFuture<U::Future, F>;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
MapFuture {
|
||||
inner: self.upgrade.upgrade_outbound(sock, info),
|
||||
map: Some(self.fun)
|
||||
@ -158,7 +157,7 @@ where
|
||||
type Error = T;
|
||||
type Future = MapErrFuture<U::Future, F>;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
MapErrFuture {
|
||||
fut: self.upgrade.upgrade_inbound(sock, info),
|
||||
fun: Some(self.fun)
|
||||
@ -174,7 +173,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = U::Future;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
self.upgrade.upgrade_outbound(sock, info)
|
||||
}
|
||||
}
|
||||
@ -210,7 +209,7 @@ where
|
||||
type Error = T;
|
||||
type Future = MapErrFuture<U::Future, F>;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
MapErrFuture {
|
||||
fut: self.upgrade.upgrade_outbound(sock, info),
|
||||
fun: Some(self.fun)
|
||||
@ -226,7 +225,7 @@ where
|
||||
type Error = U::Error;
|
||||
type Future = U::Future;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
self.upgrade.upgrade_inbound(sock, info)
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ pub trait InboundUpgrade<C>: UpgradeInfo {
|
||||
/// method is called to start the handshake.
|
||||
///
|
||||
/// The `info` is the identifier of the protocol, as produced by `protocol_info`.
|
||||
fn upgrade_inbound(self, socket: Negotiated<C>, info: Self::Info) -> Self::Future;
|
||||
fn upgrade_inbound(self, socket: C, info: Self::Info) -> Self::Future;
|
||||
}
|
||||
|
||||
/// Extension trait for `InboundUpgrade`. Automatically implemented on all types that implement
|
||||
@ -190,7 +190,7 @@ pub trait OutboundUpgrade<C>: UpgradeInfo {
|
||||
/// method is called to start the handshake.
|
||||
///
|
||||
/// The `info` is the identifier of the protocol, as produced by `protocol_info`.
|
||||
fn upgrade_outbound(self, socket: Negotiated<C>, info: Self::Info) -> Self::Future;
|
||||
fn upgrade_outbound(self, socket: C, info: Self::Info) -> Self::Future;
|
||||
}
|
||||
|
||||
/// Extention trait for `OutboundUpgrade`. Automatically implemented on all types that implement
|
||||
|
@ -19,7 +19,6 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use crate::Negotiated;
|
||||
|
||||
/// Upgrade that can be disabled at runtime.
|
||||
///
|
||||
@ -60,7 +59,7 @@ where
|
||||
type Error = T::Error;
|
||||
type Future = T::Future;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
if let Some(inner) = self.0 {
|
||||
inner.upgrade_inbound(sock, info)
|
||||
} else {
|
||||
@ -77,7 +76,7 @@ where
|
||||
type Error = T::Error;
|
||||
type Future = T::Future;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
if let Some(inner) = self.0 {
|
||||
inner.upgrade_outbound(sock, info)
|
||||
} else {
|
||||
|
@ -19,7 +19,6 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use crate::{
|
||||
Negotiated,
|
||||
either::{EitherOutput, EitherError, EitherFuture2, EitherName},
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}
|
||||
};
|
||||
@ -65,7 +64,7 @@ where
|
||||
type Error = EitherError<EA, EB>;
|
||||
type Future = EitherFuture2<A::Future, B::Future>;
|
||||
|
||||
fn upgrade_inbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
match info {
|
||||
EitherName::A(info) => EitherFuture2::A(self.0.upgrade_inbound(sock, info)),
|
||||
EitherName::B(info) => EitherFuture2::B(self.1.upgrade_inbound(sock, info))
|
||||
@ -82,7 +81,7 @@ where
|
||||
type Error = EitherError<EA, EB>;
|
||||
type Future = EitherFuture2<A::Future, B::Future>;
|
||||
|
||||
fn upgrade_outbound(self, sock: Negotiated<C>, info: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, sock: C, info: Self::Info) -> Self::Future {
|
||||
match info {
|
||||
EitherName::A(info) => EitherFuture2::A(self.0.upgrade_outbound(sock, info)),
|
||||
EitherName::B(info) => EitherFuture2::B(self.1.upgrade_outbound(sock, info))
|
||||
|
@ -23,7 +23,7 @@ mod util;
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::identity;
|
||||
use libp2p_core::transport::{Transport, MemoryTransport};
|
||||
use libp2p_core::upgrade::{self, UpgradeInfo, Negotiated, InboundUpgrade, OutboundUpgrade};
|
||||
use libp2p_core::upgrade::{self, UpgradeInfo, InboundUpgrade, OutboundUpgrade};
|
||||
use libp2p_mplex::MplexConfig;
|
||||
use libp2p_secio::SecioConfig;
|
||||
use multiaddr::{Multiaddr, Protocol};
|
||||
@ -46,11 +46,11 @@ impl<C> InboundUpgrade<C> for HelloUpgrade
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + Unpin + 'static
|
||||
{
|
||||
type Output = Negotiated<C>;
|
||||
type Output = C;
|
||||
type Error = io::Error;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send>>;
|
||||
|
||||
fn upgrade_inbound(self, mut socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, mut socket: C, _: Self::Info) -> Self::Future {
|
||||
Box::pin(async move {
|
||||
let mut buf = [0u8; 5];
|
||||
socket.read_exact(&mut buf).await.unwrap();
|
||||
@ -64,11 +64,11 @@ impl<C> OutboundUpgrade<C> for HelloUpgrade
|
||||
where
|
||||
C: AsyncWrite + AsyncRead + Send + Unpin + 'static,
|
||||
{
|
||||
type Output = Negotiated<C>;
|
||||
type Output = C;
|
||||
type Error = io::Error;
|
||||
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.write_all(b"hello").await.unwrap();
|
||||
socket.flush().await.unwrap();
|
||||
|
@ -90,8 +90,8 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
quote!{Self: #net_behv_event_proc<<#ty as #trait_to_impl>::OutEvent>},
|
||||
quote!{<<#ty as #trait_to_impl>::ProtocolsHandler as #into_protocols_handler>::Handler: #protocols_handler<Substream = #substream_generic>},
|
||||
// Note: this bound is required because of https://github.com/rust-lang/rust/issues/55697
|
||||
quote!{<<<#ty as #trait_to_impl>::ProtocolsHandler as #into_protocols_handler>::Handler as #protocols_handler>::InboundProtocol: ::libp2p::core::InboundUpgrade<#substream_generic>},
|
||||
quote!{<<<#ty as #trait_to_impl>::ProtocolsHandler as #into_protocols_handler>::Handler as #protocols_handler>::OutboundProtocol: ::libp2p::core::OutboundUpgrade<#substream_generic>},
|
||||
quote!{<<<#ty as #trait_to_impl>::ProtocolsHandler as #into_protocols_handler>::Handler as #protocols_handler>::InboundProtocol: ::libp2p::core::InboundUpgrade<::libp2p::core::Negotiated<#substream_generic>>},
|
||||
quote!{<<<#ty as #trait_to_impl>::ProtocolsHandler as #into_protocols_handler>::Handler as #protocols_handler>::OutboundProtocol: ::libp2p::core::OutboundUpgrade<::libp2p::core::Negotiated<#substream_generic>>},
|
||||
]
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -28,7 +28,7 @@ use bytes::Bytes;
|
||||
use libp2p_core::{
|
||||
Endpoint,
|
||||
StreamMuxer,
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated},
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo},
|
||||
};
|
||||
use log::{debug, trace};
|
||||
use parking_lot::Mutex;
|
||||
@ -159,11 +159,11 @@ impl<C> InboundUpgrade<C> for MplexConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
type Output = Multiplex<Negotiated<C>>;
|
||||
type Output = Multiplex<C>;
|
||||
type Error = IoError;
|
||||
type Future = future::Ready<Result<Self::Output, IoError>>;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(self.upgrade(socket)))
|
||||
}
|
||||
}
|
||||
@ -172,11 +172,11 @@ impl<C> OutboundUpgrade<C> for MplexConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
type Output = Multiplex<Negotiated<C>>;
|
||||
type Output = Multiplex<C>;
|
||||
type Error = IoError;
|
||||
type Future = future::Ready<Result<Self::Output, IoError>>;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(self.upgrade(socket)))
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
//! [specification](https://github.com/hashicorp/yamux/blob/master/spec.md).
|
||||
|
||||
use futures::{future, prelude::*, ready, stream::{BoxStream, LocalBoxStream}};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, Negotiated};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use parking_lot::Mutex;
|
||||
use std::{fmt, io, iter, pin::Pin, task::Context};
|
||||
use thiserror::Error;
|
||||
@ -205,11 +205,11 @@ impl<C> InboundUpgrade<C> for Config
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + Unpin + 'static
|
||||
{
|
||||
type Output = Yamux<Incoming<Negotiated<C>>>;
|
||||
type Output = Yamux<Incoming<C>>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, io: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, io: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(Yamux::new(io, self.0, yamux::Mode::Server)))
|
||||
}
|
||||
}
|
||||
@ -218,11 +218,11 @@ impl<C> InboundUpgrade<C> for LocalConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin + 'static
|
||||
{
|
||||
type Output = Yamux<LocalIncoming<Negotiated<C>>>;
|
||||
type Output = Yamux<LocalIncoming<C>>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, io: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, io: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(Yamux::local(io, (self.0).0, yamux::Mode::Server)))
|
||||
}
|
||||
}
|
||||
@ -231,11 +231,11 @@ impl<C> OutboundUpgrade<C> for Config
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Send + Unpin + 'static
|
||||
{
|
||||
type Output = Yamux<Incoming<Negotiated<C>>>;
|
||||
type Output = Yamux<Incoming<C>>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, io: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, io: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(Yamux::new(io, self.0, yamux::Mode::Client)))
|
||||
}
|
||||
}
|
||||
@ -244,11 +244,11 @@ impl<C> OutboundUpgrade<C> for LocalConfig
|
||||
where
|
||||
C: AsyncRead + AsyncWrite + Unpin + 'static
|
||||
{
|
||||
type Output = Yamux<LocalIncoming<Negotiated<C>>>;
|
||||
type Output = Yamux<LocalIncoming<C>>;
|
||||
type Error = io::Error;
|
||||
type Future = future::Ready<Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, io: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, io: C, _: Self::Info) -> Self::Future {
|
||||
future::ready(Ok(Yamux::local(io, (self.0).0, yamux::Mode::Client)))
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
// 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, Negotiated};
|
||||
use crate::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
|
||||
use bytes::Bytes;
|
||||
use futures::prelude::*;
|
||||
use std::{iter, sync::Arc};
|
||||
@ -66,14 +66,14 @@ impl<F> UpgradeInfo for SimpleProtocol<F> {
|
||||
impl<C, F, O, A, E> InboundUpgrade<C> for SimpleProtocol<F>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite,
|
||||
F: Fn(Negotiated<C>) -> O,
|
||||
F: Fn(C) -> O,
|
||||
O: Future<Output = Result<A, E>> + Unpin
|
||||
{
|
||||
type Output = A;
|
||||
type Error = E;
|
||||
type Future = O;
|
||||
|
||||
fn upgrade_inbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
let upgrade = &self.upgrade;
|
||||
upgrade(socket)
|
||||
}
|
||||
@ -82,14 +82,14 @@ where
|
||||
impl<C, F, O, A, E> OutboundUpgrade<C> for SimpleProtocol<F>
|
||||
where
|
||||
C: AsyncRead + AsyncWrite,
|
||||
F: Fn(Negotiated<C>) -> O,
|
||||
F: Fn(C) -> O,
|
||||
O: Future<Output = Result<A, E>> + Unpin
|
||||
{
|
||||
type Output = A;
|
||||
type Error = E;
|
||||
type Future = O;
|
||||
|
||||
fn upgrade_outbound(self, socket: Negotiated<C>, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, socket: C, _: Self::Info) -> Self::Future {
|
||||
let upgrade = &self.upgrade;
|
||||
upgrade(socket)
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ pub use protocols_handler::{
|
||||
use protocols_handler::{NodeHandlerWrapperBuilder, NodeHandlerWrapper, NodeHandlerWrapperError};
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
Transport, Multiaddr, PeerId, InboundUpgrade, OutboundUpgrade, UpgradeInfo, ProtocolName,
|
||||
Transport, Multiaddr, Negotiated, PeerId, InboundUpgrade, OutboundUpgrade, UpgradeInfo, ProtocolName,
|
||||
muxing::StreamMuxer,
|
||||
nodes::{
|
||||
ListenerId,
|
||||
@ -217,18 +217,18 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::Error: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<NodeHandlerWrapper<<THandler as IntoProtocolsHandler>::Handler> as NodeHandler>::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
|
||||
TConnInfo: ConnectionInfo<PeerId = PeerId> + fmt::Debug + Clone + Send + 'static,
|
||||
{
|
||||
@ -512,15 +512,15 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::Error: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<THandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
@ -593,18 +593,18 @@ where TBehaviour: NetworkBehaviour,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent: Send + 'static,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::Error: Send + 'static,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Substream<TMuxer>> + Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InboundProtocol as InboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Negotiated<Substream<TMuxer>>> + Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::Info: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter: Send + 'static,
|
||||
<<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Future: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Substream<TMuxer>>>::Error: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Future: Send + 'static,
|
||||
<<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutboundProtocol as OutboundUpgrade<Negotiated<Substream<TMuxer>>>>::Error: Send + 'static,
|
||||
<NodeHandlerWrapper<<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler> as NodeHandler>::OutboundOpenInfo: Send + 'static, // TODO: shouldn't be necessary
|
||||
TConnInfo: ConnectionInfo<PeerId = PeerId> + fmt::Debug + Clone + Send + 'static,
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ use crate::protocols_handler::{
|
||||
ProtocolsHandlerUpgrErr
|
||||
};
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade, DeniedUpgrade};
|
||||
use libp2p_core::{Negotiated, upgrade::{InboundUpgrade, OutboundUpgrade, DeniedUpgrade}};
|
||||
use std::{marker::PhantomData, task::Context, task::Poll};
|
||||
use void::Void;
|
||||
|
||||
@ -64,14 +64,14 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
_: <Self::InboundProtocol as InboundUpgrade<TSubstream>>::Output
|
||||
_: <Self::InboundProtocol as InboundUpgrade<Negotiated<TSubstream>>>::Output
|
||||
) {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
_: <Self::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output,
|
||||
_: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<TSubstream>>>::Output,
|
||||
_: Self::OutboundOpenInfo
|
||||
) {
|
||||
}
|
||||
@ -80,7 +80,7 @@ where
|
||||
fn inject_event(&mut self, _: Self::InEvent) {}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {}
|
||||
fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error>) {}
|
||||
|
||||
#[inline]
|
||||
fn connection_keep_alive(&self) -> KeepAlive { KeepAlive::No }
|
||||
|
@ -25,7 +25,7 @@ use crate::protocols_handler::{
|
||||
ProtocolsHandlerEvent,
|
||||
ProtocolsHandlerUpgrErr
|
||||
};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade};
|
||||
use libp2p_core::{Negotiated, upgrade::{InboundUpgrade, OutboundUpgrade}};
|
||||
use std::{marker::PhantomData, task::Context, task::Poll};
|
||||
|
||||
/// Wrapper around a protocol handler that turns the input event into something else.
|
||||
@ -68,7 +68,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<Self::Substream>>>::Output
|
||||
) {
|
||||
self.inner.inject_fully_negotiated_inbound(protocol)
|
||||
}
|
||||
@ -76,7 +76,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
info: Self::OutboundOpenInfo
|
||||
) {
|
||||
self.inner.inject_fully_negotiated_outbound(protocol, info)
|
||||
@ -90,7 +90,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error>) {
|
||||
self.inner.inject_dial_upgrade_error(info, error)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ use crate::protocols_handler::{
|
||||
ProtocolsHandlerEvent,
|
||||
ProtocolsHandlerUpgrErr
|
||||
};
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade};
|
||||
use libp2p_core::{Negotiated, upgrade::{InboundUpgrade, OutboundUpgrade}};
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
/// Wrapper around a protocol handler that turns the output event into something else.
|
||||
@ -66,7 +66,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<Self::Substream>>>::Output
|
||||
) {
|
||||
self.inner.inject_fully_negotiated_inbound(protocol)
|
||||
}
|
||||
@ -74,7 +74,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
info: Self::OutboundOpenInfo
|
||||
) {
|
||||
self.inner.inject_fully_negotiated_outbound(protocol, info)
|
||||
@ -86,7 +86,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error>) {
|
||||
self.inner.inject_dial_upgrade_error(info, error)
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ mod select;
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
ConnectedPoint,
|
||||
Negotiated,
|
||||
PeerId,
|
||||
upgrade::{self, InboundUpgrade, OutboundUpgrade, UpgradeError},
|
||||
};
|
||||
@ -102,9 +103,9 @@ pub trait ProtocolsHandler {
|
||||
/// The type of substreams on which the protocol(s) are negotiated.
|
||||
type Substream: AsyncRead + AsyncWrite + Unpin;
|
||||
/// The inbound upgrade for the protocol(s) used by the handler.
|
||||
type InboundProtocol: InboundUpgrade<Self::Substream>;
|
||||
type InboundProtocol: InboundUpgrade<Negotiated<Self::Substream>>;
|
||||
/// The outbound upgrade for the protocol(s) used by the handler.
|
||||
type OutboundProtocol: OutboundUpgrade<Self::Substream>;
|
||||
type OutboundProtocol: OutboundUpgrade<Negotiated<Self::Substream>>;
|
||||
/// The type of additional information passed to an `OutboundSubstreamRequest`.
|
||||
type OutboundOpenInfo;
|
||||
|
||||
@ -120,7 +121,7 @@ pub trait ProtocolsHandler {
|
||||
/// Injects the output of a successful upgrade on a new inbound substream.
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
|
||||
protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<Self::Substream>>>::Output
|
||||
);
|
||||
|
||||
/// Injects the output of a successful upgrade on a new outbound substream.
|
||||
@ -129,7 +130,7 @@ pub trait ProtocolsHandler {
|
||||
/// [`ProtocolsHandlerEvent::OutboundSubstreamRequest`].
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
|
||||
protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
info: Self::OutboundOpenInfo
|
||||
);
|
||||
|
||||
@ -141,7 +142,7 @@ pub trait ProtocolsHandler {
|
||||
&mut self,
|
||||
info: Self::OutboundOpenInfo,
|
||||
error: ProtocolsHandlerUpgrErr<
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error
|
||||
>
|
||||
);
|
||||
|
||||
|
@ -26,7 +26,7 @@ use crate::protocols_handler::{
|
||||
SubstreamProtocol
|
||||
};
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::upgrade::{InboundUpgrade, OutboundUpgrade};
|
||||
use libp2p_core::{Negotiated, upgrade::{InboundUpgrade, OutboundUpgrade}};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, marker::PhantomData, task::Context, task::Poll, time::Duration};
|
||||
use wasm_timer::Instant;
|
||||
@ -37,13 +37,13 @@ use wasm_timer::Instant;
|
||||
// TODO: Debug
|
||||
pub struct OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent>
|
||||
where
|
||||
TOutProto: OutboundUpgrade<TSubstream>,
|
||||
TOutProto: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
{
|
||||
/// The upgrade for inbound substreams.
|
||||
listen_protocol: SubstreamProtocol<TInProto>,
|
||||
/// If `Some`, something bad happened and we should shut down the handler with an error.
|
||||
pending_error:
|
||||
Option<ProtocolsHandlerUpgrErr<<TOutProto as OutboundUpgrade<TSubstream>>::Error>>,
|
||||
Option<ProtocolsHandlerUpgrErr<<TOutProto as OutboundUpgrade<Negotiated<TSubstream>>>::Error>>,
|
||||
/// Queue of events to produce in `poll()`.
|
||||
events_out: SmallVec<[TOutEvent; 4]>,
|
||||
/// Queue of outbound substreams to open.
|
||||
@ -63,7 +63,7 @@ where
|
||||
impl<TSubstream, TInProto, TOutProto, TOutEvent>
|
||||
OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent>
|
||||
where
|
||||
TOutProto: OutboundUpgrade<TSubstream>,
|
||||
TOutProto: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
{
|
||||
/// Creates a `OneShotHandler`.
|
||||
#[inline]
|
||||
@ -119,8 +119,8 @@ where
|
||||
impl<TSubstream, TInProto, TOutProto, TOutEvent> Default
|
||||
for OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent>
|
||||
where
|
||||
TOutProto: OutboundUpgrade<TSubstream>,
|
||||
TInProto: InboundUpgrade<TSubstream> + Default,
|
||||
TOutProto: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
TInProto: InboundUpgrade<Negotiated<TSubstream>> + Default,
|
||||
{
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
@ -132,8 +132,8 @@ impl<TSubstream, TInProto, TOutProto, TOutEvent> ProtocolsHandler
|
||||
for OneShotHandler<TSubstream, TInProto, TOutProto, TOutEvent>
|
||||
where
|
||||
TSubstream: AsyncRead + AsyncWrite + Unpin,
|
||||
TInProto: InboundUpgrade<TSubstream>,
|
||||
TOutProto: OutboundUpgrade<TSubstream>,
|
||||
TInProto: InboundUpgrade<Negotiated<TSubstream>>,
|
||||
TOutProto: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
TInProto::Output: Into<TOutEvent>,
|
||||
TOutProto::Output: Into<TOutEvent>,
|
||||
TOutProto::Error: error::Error + 'static,
|
||||
@ -142,7 +142,7 @@ where
|
||||
type InEvent = TOutProto;
|
||||
type OutEvent = TOutEvent;
|
||||
type Error = ProtocolsHandlerUpgrErr<
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error,
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error,
|
||||
>;
|
||||
type Substream = TSubstream;
|
||||
type InboundProtocol = TInProto;
|
||||
@ -157,7 +157,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
out: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output,
|
||||
out: <Self::InboundProtocol as InboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
) {
|
||||
// If we're shutting down the connection for inactivity, reset the timeout.
|
||||
if !self.keep_alive.is_yes() {
|
||||
@ -170,7 +170,7 @@ where
|
||||
#[inline]
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
out: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
|
||||
out: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
_: Self::OutboundOpenInfo,
|
||||
) {
|
||||
self.dial_negotiated -= 1;
|
||||
@ -192,7 +192,7 @@ where
|
||||
&mut self,
|
||||
_: Self::OutboundOpenInfo,
|
||||
error: ProtocolsHandlerUpgrErr<
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error,
|
||||
<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error,
|
||||
>,
|
||||
) {
|
||||
if self.pending_error.is_none() {
|
||||
|
@ -29,6 +29,7 @@ use crate::protocols_handler::{
|
||||
use futures::prelude::*;
|
||||
use libp2p_core::{
|
||||
ConnectedPoint,
|
||||
Negotiated,
|
||||
PeerId,
|
||||
either::{EitherError, EitherOutput},
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, EitherUpgrade, SelectUpgrade, UpgradeError}
|
||||
@ -62,10 +63,10 @@ where
|
||||
TProto1::Handler: ProtocolsHandler<Substream = TSubstream>,
|
||||
TProto2::Handler: ProtocolsHandler<Substream = TSubstream>,
|
||||
TSubstream: AsyncRead + AsyncWrite + Unpin,
|
||||
<TProto1::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
|
||||
<TProto2::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<TSubstream>,
|
||||
<TProto1::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>,
|
||||
<TProto2::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<TSubstream>
|
||||
<TProto1::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Negotiated<TSubstream>>,
|
||||
<TProto2::Handler as ProtocolsHandler>::InboundProtocol: InboundUpgrade<Negotiated<TSubstream>>,
|
||||
<TProto1::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
<TProto2::Handler as ProtocolsHandler>::OutboundProtocol: OutboundUpgrade<Negotiated<TSubstream>>
|
||||
{
|
||||
type Handler = ProtocolsHandlerSelect<TProto1::Handler, TProto2::Handler>;
|
||||
|
||||
@ -107,10 +108,10 @@ where
|
||||
TProto1: ProtocolsHandler<Substream = TSubstream>,
|
||||
TProto2: ProtocolsHandler<Substream = TSubstream>,
|
||||
TSubstream: AsyncRead + AsyncWrite + Unpin,
|
||||
TProto1::InboundProtocol: InboundUpgrade<TSubstream>,
|
||||
TProto2::InboundProtocol: InboundUpgrade<TSubstream>,
|
||||
TProto1::OutboundProtocol: OutboundUpgrade<TSubstream>,
|
||||
TProto2::OutboundProtocol: OutboundUpgrade<TSubstream>
|
||||
TProto1::InboundProtocol: InboundUpgrade<Negotiated<TSubstream>>,
|
||||
TProto2::InboundProtocol: InboundUpgrade<Negotiated<TSubstream>>,
|
||||
TProto1::OutboundProtocol: OutboundUpgrade<Negotiated<TSubstream>>,
|
||||
TProto2::OutboundProtocol: OutboundUpgrade<Negotiated<TSubstream>>
|
||||
{
|
||||
type InEvent = EitherOutput<TProto1::InEvent, TProto2::InEvent>;
|
||||
type OutEvent = EitherOutput<TProto1::OutEvent, TProto2::OutEvent>;
|
||||
@ -129,7 +130,7 @@ where
|
||||
SubstreamProtocol::new(choice).with_timeout(timeout)
|
||||
}
|
||||
|
||||
fn inject_fully_negotiated_outbound(&mut self, protocol: <Self::OutboundProtocol as OutboundUpgrade<TSubstream>>::Output, endpoint: Self::OutboundOpenInfo) {
|
||||
fn inject_fully_negotiated_outbound(&mut self, protocol: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<TSubstream>>>::Output, endpoint: Self::OutboundOpenInfo) {
|
||||
match (protocol, endpoint) {
|
||||
(EitherOutput::First(protocol), EitherOutput::First(info)) =>
|
||||
self.proto1.inject_fully_negotiated_outbound(protocol, info),
|
||||
@ -142,7 +143,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_fully_negotiated_inbound(&mut self, protocol: <Self::InboundProtocol as InboundUpgrade<TSubstream>>::Output) {
|
||||
fn inject_fully_negotiated_inbound(&mut self, protocol: <Self::InboundProtocol as InboundUpgrade<Negotiated<TSubstream>>>::Output) {
|
||||
match protocol {
|
||||
EitherOutput::First(protocol) =>
|
||||
self.proto1.inject_fully_negotiated_inbound(protocol),
|
||||
@ -160,7 +161,7 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, error: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error>) {
|
||||
match (info, error) {
|
||||
(EitherOutput::First(info), ProtocolsHandlerUpgrErr::Timer) => {
|
||||
self.proto1.inject_dial_upgrade_error(info, ProtocolsHandlerUpgrErr::Timer)
|
||||
|
@ -31,6 +31,7 @@ use libp2p_core::{
|
||||
ConnectedPoint,
|
||||
PeerId,
|
||||
Multiaddr,
|
||||
Negotiated,
|
||||
either::EitherOutput,
|
||||
upgrade::{InboundUpgrade, OutboundUpgrade, DeniedUpgrade, EitherUpgrade}
|
||||
};
|
||||
@ -206,7 +207,7 @@ where
|
||||
|
||||
fn inject_fully_negotiated_inbound(
|
||||
&mut self,
|
||||
out: <Self::InboundProtocol as InboundUpgrade<Self::Substream>>::Output
|
||||
out: <Self::InboundProtocol as InboundUpgrade<Negotiated<Self::Substream>>>::Output
|
||||
) {
|
||||
let out = match out {
|
||||
EitherOutput::First(out) => out,
|
||||
@ -219,7 +220,7 @@ where
|
||||
|
||||
fn inject_fully_negotiated_outbound(
|
||||
&mut self,
|
||||
out: <Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Output,
|
||||
out: <Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Output,
|
||||
info: Self::OutboundOpenInfo
|
||||
) {
|
||||
self.inner.as_mut().expect("Can't receive an outbound substream if disabled; QED")
|
||||
@ -231,7 +232,7 @@ where
|
||||
.inject_event(event)
|
||||
}
|
||||
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, err: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Self::Substream>>::Error>) {
|
||||
fn inject_dial_upgrade_error(&mut self, info: Self::OutboundOpenInfo, err: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<Negotiated<Self::Substream>>>::Error>) {
|
||||
self.inner.as_mut().expect("Can't receive an outbound substream if disabled; QED")
|
||||
.inject_dial_upgrade_error(info, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user