mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 00:41:59 +00:00
feat(swarm): deprecate NegotiatedSubstream
in favor of Stream
This patch tackles two things at once that are fairly intertwined: 1. There is no such thing as a "substream" in libp2p, the spec and other implementations only talk about "streams". We fix this by deprecating `NegotiatedSubstream`. 2. Previously, `NegotiatedSubstream` was a type alias that pointed to a type from `multistream-select`, effectively leaking the version of `multistream-select` to all dependencies of `libp2p-swarm`. We fix this by introducing a `Stream` newtype. Resolves: #3759. Related: #3748. Pull-Request: #3912.
This commit is contained in:
@@ -22,7 +22,7 @@ use crate::proto;
|
||||
use asynchronous_codec::Framed;
|
||||
use futures::{future::BoxFuture, prelude::*};
|
||||
use libp2p_core::{multiaddr::Protocol, upgrade, Multiaddr};
|
||||
use libp2p_swarm::{NegotiatedSubstream, StreamProtocol};
|
||||
use libp2p_swarm::{Stream, StreamProtocol};
|
||||
use std::convert::TryFrom;
|
||||
use std::iter;
|
||||
use thiserror::Error;
|
||||
@@ -38,12 +38,12 @@ impl upgrade::UpgradeInfo for Upgrade {
|
||||
}
|
||||
}
|
||||
|
||||
impl upgrade::InboundUpgrade<NegotiatedSubstream> for Upgrade {
|
||||
impl upgrade::InboundUpgrade<Stream> for Upgrade {
|
||||
type Output = PendingConnect;
|
||||
type Error = UpgradeError;
|
||||
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_inbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_inbound(self, substream: Stream, _: Self::Info) -> Self::Future {
|
||||
let mut substream = Framed::new(
|
||||
substream,
|
||||
quick_protobuf_codec::Codec::new(super::MAX_MESSAGE_SIZE_BYTES),
|
||||
@@ -92,7 +92,7 @@ impl upgrade::InboundUpgrade<NegotiatedSubstream> for Upgrade {
|
||||
}
|
||||
|
||||
pub struct PendingConnect {
|
||||
substream: Framed<NegotiatedSubstream, quick_protobuf_codec::Codec<proto::HolePunch>>,
|
||||
substream: Framed<Stream, quick_protobuf_codec::Codec<proto::HolePunch>>,
|
||||
remote_obs_addrs: Vec<Multiaddr>,
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ use futures::{future::BoxFuture, prelude::*};
|
||||
use futures_timer::Delay;
|
||||
use instant::Instant;
|
||||
use libp2p_core::{multiaddr::Protocol, upgrade, Multiaddr};
|
||||
use libp2p_swarm::{NegotiatedSubstream, StreamProtocol};
|
||||
use libp2p_swarm::{Stream, StreamProtocol};
|
||||
use std::convert::TryFrom;
|
||||
use std::iter;
|
||||
use thiserror::Error;
|
||||
@@ -48,12 +48,12 @@ impl Upgrade {
|
||||
}
|
||||
}
|
||||
|
||||
impl upgrade::OutboundUpgrade<NegotiatedSubstream> for Upgrade {
|
||||
impl upgrade::OutboundUpgrade<Stream> for Upgrade {
|
||||
type Output = Connect;
|
||||
type Error = UpgradeError;
|
||||
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;
|
||||
|
||||
fn upgrade_outbound(self, substream: NegotiatedSubstream, _: Self::Info) -> Self::Future {
|
||||
fn upgrade_outbound(self, substream: Stream, _: Self::Info) -> Self::Future {
|
||||
let mut substream = Framed::new(
|
||||
substream,
|
||||
quick_protobuf_codec::Codec::new(super::MAX_MESSAGE_SIZE_BYTES),
|
||||
|
Reference in New Issue
Block a user