Update muxers to edition 2018 (#788)

* Upgrade mplex to edition 2018

* Upgrade yamux to edition 2018
This commit is contained in:
Pierre Krieger 2018-12-18 11:06:37 +01:00 committed by GitHub
parent 60dca37bb7
commit af698a1ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 36 deletions

View File

@ -1,5 +1,6 @@
[package]
name = "libp2p-mplex"
edition = "2018"
description = "Mplex multiplexing protocol for libp2p"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

View File

@ -18,10 +18,10 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
use libp2p_core::Endpoint;
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::mem;
use bytes::{BufMut, Bytes, BytesMut};
use core::Endpoint;
use tokio_io::codec::{Decoder, Encoder};
use unsigned_varint::{codec, encode};

View File

@ -18,34 +18,22 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
extern crate bytes;
extern crate fnv;
#[macro_use]
extern crate futures;
extern crate libp2p_core as core;
#[macro_use]
extern crate log;
extern crate parking_lot;
extern crate tokio_codec;
extern crate tokio_io;
extern crate unsigned_varint;
mod codec;
use std::{cmp, iter, mem};
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use std::sync::{atomic::AtomicUsize, atomic::Ordering, Arc};
use bytes::Bytes;
use core::{
use libp2p_core::{
Endpoint,
StreamMuxer,
muxing::Shutdown,
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}
};
use log::{debug, trace};
use parking_lot::Mutex;
use fnv::{FnvHashMap, FnvHashSet};
use futures::prelude::*;
use futures::{executor, future, stream::Fuse, task};
use futures::{prelude::*, executor, future, stream::Fuse, task, task_local, try_ready};
use tokio_codec::Framed;
use tokio_io::{AsyncRead, AsyncWrite};

View File

@ -18,18 +18,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
extern crate bytes;
extern crate futures;
extern crate libp2p_mplex as multiplex;
extern crate libp2p_core as swarm;
extern crate libp2p_tcp as tcp;
extern crate tokio;
use libp2p_core::{muxing, Transport};
use libp2p_tcp::TcpConfig;
use futures::prelude::*;
use std::sync::{Arc, mpsc};
use std::thread;
use swarm::{muxing, Transport};
use tcp::TcpConfig;
use tokio::{
codec::length_delimited::Builder,
runtime::current_thread::Runtime
@ -43,7 +36,7 @@ fn client_to_server_outbound() {
let bg_thread = thread::spawn(move || {
let transport =
TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
let (listener, addr) = transport
.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap())
@ -72,7 +65,7 @@ fn client_to_server_outbound() {
let _ = rt.block_on(future).unwrap();
});
let transport = TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
let transport = TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
let future = transport
.dial(rx.recv().unwrap())
@ -95,7 +88,7 @@ fn client_to_server_inbound() {
let bg_thread = thread::spawn(move || {
let transport =
TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
let (listener, addr) = transport
.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap())
@ -124,7 +117,7 @@ fn client_to_server_inbound() {
let _ = rt.block_on(future).unwrap();
});
let transport = TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
let transport = TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
let future = transport
.dial(rx.recv().unwrap())

View File

@ -1,5 +1,6 @@
[package]
name = "libp2p-yamux"
edition = "2018"
description = "Yamux multiplexing protocol for libp2p"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

View File

@ -21,15 +21,9 @@
//! Implements the Yamux multiplexing protocol for libp2p, see also the
//! [specification](https://github.com/hashicorp/yamux/blob/master/spec.md).
extern crate futures;
#[macro_use]
extern crate log;
extern crate libp2p_core;
extern crate tokio_io;
extern crate yamux;
use futures::{future::{self, FutureResult}, prelude::*};
use libp2p_core::{muxing::Shutdown, upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}};
use log::error;
use std::{io, iter};
use std::io::{Error as IoError};
use tokio_io::{AsyncRead, AsyncWrite};