mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-08-01 01:11:58 +00:00
Merge the changes from polkadot-2 into master (#446)
This commit is contained in:
committed by
Benjamin Kampmann
parent
35e005879b
commit
f787c80a42
File diff suppressed because it is too large
Load Diff
@@ -29,8 +29,10 @@
|
||||
//! `UpgradedNode::or_upgrade` methods, you can combine multiple transports and/or upgrades
|
||||
//! together in a complex chain of protocols negotiation.
|
||||
|
||||
use connection_reuse::ConnectionReuse;
|
||||
use futures::prelude::*;
|
||||
use multiaddr::Multiaddr;
|
||||
use muxing::StreamMuxer;
|
||||
use std::io::Error as IoError;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use upgrade::{ConnectionUpgrade, Endpoint};
|
||||
@@ -116,7 +118,7 @@ pub trait Transport {
|
||||
/// implementation of `Transport` is only responsible for handling the protocols it supports.
|
||||
///
|
||||
/// Returns `None` if nothing can be determined. This happens if this trait implementation
|
||||
/// doesn't recognize the protocols, or if `server` and `observed` are unrelated.
|
||||
/// doesn't recognize the protocols, or if `server` and `observed` are related.
|
||||
fn nat_traversal(&self, server: &Multiaddr, observed: &Multiaddr) -> Option<Multiaddr>;
|
||||
|
||||
/// Applies a function on the output of the `Transport`.
|
||||
@@ -207,6 +209,17 @@ pub trait Transport {
|
||||
DummyMuxing::new(self)
|
||||
}
|
||||
|
||||
/// Turns this `Transport` into a `ConnectionReuse`. If the `Output` implements the
|
||||
/// `StreamMuxer` trait, the returned object will implement `Transport` and `MuxedTransport`.
|
||||
#[inline]
|
||||
fn into_connection_reuse<D, M>(self) -> ConnectionReuse<Self, D, M>
|
||||
where
|
||||
Self: Sized + Transport<Output = (D, M)>,
|
||||
M: StreamMuxer,
|
||||
{
|
||||
ConnectionReuse::new(self)
|
||||
}
|
||||
|
||||
/// Wraps around the `Transport` and makes it interruptible.
|
||||
#[inline]
|
||||
fn interruptible(self) -> (interruptible::Interruptible<Self>, interruptible::Interrupt)
|
||||
|
@@ -18,10 +18,8 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use connection_reuse::ConnectionReuse;
|
||||
use futures::prelude::*;
|
||||
use multiaddr::Multiaddr;
|
||||
use muxing::StreamMuxer;
|
||||
use std::io::Error as IoError;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use transport::{MuxedTransport, Transport};
|
||||
@@ -52,16 +50,6 @@ where
|
||||
T::Output: AsyncRead + AsyncWrite,
|
||||
C: ConnectionUpgrade<T::Output, T::MultiaddrFuture> + 'a,
|
||||
{
|
||||
/// Turns this upgraded node into a `ConnectionReuse`. If the `Output` implements the
|
||||
/// `StreamMuxer` trait, the returned object will implement `Transport` and `MuxedTransport`.
|
||||
#[inline]
|
||||
pub fn into_connection_reuse(self) -> ConnectionReuse<T, C>
|
||||
where
|
||||
C::Output: StreamMuxer,
|
||||
{
|
||||
From::from(self)
|
||||
}
|
||||
|
||||
/// Returns a reference to the inner `Transport`.
|
||||
#[inline]
|
||||
pub fn transport(&self) -> &T {
|
||||
|
Reference in New Issue
Block a user