Skip to content

Commit

Permalink
feat(network): use yamux to do multiplex
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr authored and doitian committed Nov 19, 2018
1 parent 2ab0d7f commit 83824d5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions network/src/transport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use libp2p::core::{either, transport::BoxedMuxed, upgrade, Multiaddr, PeerId, Transport};
use libp2p::core::{transport::BoxedMuxed, upgrade, Multiaddr, PeerId, Transport};
use libp2p::{self, mplex, secio, yamux, TransportTimeout};
use std::time::Duration;
use std::usize;
Expand All @@ -16,13 +16,8 @@ pub fn new_transport(
.with_upgrade(secio::SecioConfig {
key: local_private_key,
}).and_then(move |out, endpoint, client_addr| {
// TODO: find out what is yamux?
let upgrade = upgrade::or(
upgrade::map(mplex_config, either::EitherOutput::First),
upgrade::map(yamux::Config::default(), either::EitherOutput::Second),
);
let key = out.remote_key;
let upgrade = upgrade::map(upgrade, move |muxer| (key, muxer));
let upgrade = upgrade::map(yamux::Config::default(), move |muxer| (key, muxer));
upgrade::apply(out.stream, upgrade, endpoint, client_addr)
// TODO: check key
}).into_connection_reuse()
Expand Down

0 comments on commit 83824d5

Please sign in to comment.