diff --git a/substrate/core/network/src/lib.rs b/substrate/core/network/src/lib.rs index 33f9e5d2eb8ddf83619254302eeaab8696d420b2..e5714c66f20a52a9762e3c8687b48d12b53f4a8a 100644 --- a/substrate/core/network/src/lib.rs +++ b/substrate/core/network/src/lib.rs @@ -89,6 +89,8 @@ //! //! The following multiplexing protocols are supported: //! +//! - [Mplex](https://github.com/libp2p/specs/tree/master/mplex). Support for mplex will likely +//! be deprecated in the future. //! - [Yamux](https://github.com/hashicorp/yamux/blob/master/spec.md). //! //! ## Substreams diff --git a/substrate/core/network/src/transport.rs b/substrate/core/network/src/transport.rs index 389a6626610bcb951890a7f430b5f60e3e11dcc3..901ec18581e1d3e851034bb8a97e9154c786890d 100644 --- a/substrate/core/network/src/transport.rs +++ b/substrate/core/network/src/transport.rs @@ -17,14 +17,14 @@ use futures::prelude::*; use libp2p::{ InboundUpgradeExt, OutboundUpgradeExt, PeerId, Transport, - identity, secio, yamux, bandwidth, wasm_ext + mplex, identity, secio, yamux, bandwidth, wasm_ext }; #[cfg(not(target_os = "unknown"))] use libp2p::{tcp, dns, websocket, noise}; #[cfg(not(target_os = "unknown"))] use libp2p::core::{upgrade, either::EitherError, either::EitherOutput}; use libp2p::core::{self, transport::boxed::Boxed, transport::OptionalTransport, muxing::StreamMuxerBox}; -use std::{io, sync::Arc, time::Duration}; +use std::{io, sync::Arc, time::Duration, usize}; pub use self::bandwidth::BandwidthSinks; @@ -55,6 +55,9 @@ pub fn build_transport( let secio_config = secio::SecioConfig::new(keypair); // Build configuration objects for multiplexing mechanisms. + let mut mplex_config = mplex::MplexConfig::new(); + mplex_config.max_buffer_len_behaviour(mplex::MaxBufferBehaviour::Block); + mplex_config.max_buffer_len(usize::MAX); let yamux_config = yamux::Config::default(); // Build the base layer of the transport. @@ -113,7 +116,7 @@ pub fn build_transport( // Multiplexing let transport = transport.and_then(move |(stream, peer_id), endpoint| { let peer_id2 = peer_id.clone(); - let upgrade = yamux_config + let upgrade = core::upgrade::SelectUpgrade::new(yamux_config, mplex_config) .map_inbound(move |muxer| (peer_id, muxer)) .map_outbound(move |muxer| (peer_id2, muxer));