mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-04 15:12:15 +00:00
Update muxers to edition 2018 (#788)
* Upgrade mplex to edition 2018 * Upgrade yamux to edition 2018
This commit is contained in:
parent
60dca37bb7
commit
af698a1ce7
@ -1,5 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "libp2p-mplex"
|
name = "libp2p-mplex"
|
||||||
|
edition = "2018"
|
||||||
description = "Mplex multiplexing protocol for libp2p"
|
description = "Mplex multiplexing protocol for libp2p"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
use libp2p_core::Endpoint;
|
||||||
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
use bytes::{BufMut, Bytes, BytesMut};
|
||||||
use core::Endpoint;
|
|
||||||
use tokio_io::codec::{Decoder, Encoder};
|
use tokio_io::codec::{Decoder, Encoder};
|
||||||
use unsigned_varint::{codec, encode};
|
use unsigned_varint::{codec, encode};
|
||||||
|
|
||||||
|
@ -18,34 +18,22 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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;
|
mod codec;
|
||||||
|
|
||||||
use std::{cmp, iter, mem};
|
use std::{cmp, iter, mem};
|
||||||
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
||||||
use std::sync::{atomic::AtomicUsize, atomic::Ordering, Arc};
|
use std::sync::{atomic::AtomicUsize, atomic::Ordering, Arc};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use core::{
|
use libp2p_core::{
|
||||||
Endpoint,
|
Endpoint,
|
||||||
StreamMuxer,
|
StreamMuxer,
|
||||||
muxing::Shutdown,
|
muxing::Shutdown,
|
||||||
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}
|
upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}
|
||||||
};
|
};
|
||||||
|
use log::{debug, trace};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use fnv::{FnvHashMap, FnvHashSet};
|
use fnv::{FnvHashMap, FnvHashSet};
|
||||||
use futures::prelude::*;
|
use futures::{prelude::*, executor, future, stream::Fuse, task, task_local, try_ready};
|
||||||
use futures::{executor, future, stream::Fuse, task};
|
|
||||||
use tokio_codec::Framed;
|
use tokio_codec::Framed;
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
|
|
||||||
|
@ -18,18 +18,11 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
extern crate bytes;
|
use libp2p_core::{muxing, Transport};
|
||||||
extern crate futures;
|
use libp2p_tcp::TcpConfig;
|
||||||
extern crate libp2p_mplex as multiplex;
|
|
||||||
extern crate libp2p_core as swarm;
|
|
||||||
extern crate libp2p_tcp as tcp;
|
|
||||||
extern crate tokio;
|
|
||||||
|
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use std::sync::{Arc, mpsc};
|
use std::sync::{Arc, mpsc};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use swarm::{muxing, Transport};
|
|
||||||
use tcp::TcpConfig;
|
|
||||||
use tokio::{
|
use tokio::{
|
||||||
codec::length_delimited::Builder,
|
codec::length_delimited::Builder,
|
||||||
runtime::current_thread::Runtime
|
runtime::current_thread::Runtime
|
||||||
@ -43,7 +36,7 @@ fn client_to_server_outbound() {
|
|||||||
|
|
||||||
let bg_thread = thread::spawn(move || {
|
let bg_thread = thread::spawn(move || {
|
||||||
let transport =
|
let transport =
|
||||||
TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
|
TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
|
||||||
|
|
||||||
let (listener, addr) = transport
|
let (listener, addr) = transport
|
||||||
.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap())
|
.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 _ = 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
|
let future = transport
|
||||||
.dial(rx.recv().unwrap())
|
.dial(rx.recv().unwrap())
|
||||||
@ -95,7 +88,7 @@ fn client_to_server_inbound() {
|
|||||||
|
|
||||||
let bg_thread = thread::spawn(move || {
|
let bg_thread = thread::spawn(move || {
|
||||||
let transport =
|
let transport =
|
||||||
TcpConfig::new().with_upgrade(multiplex::MplexConfig::new());
|
TcpConfig::new().with_upgrade(libp2p_mplex::MplexConfig::new());
|
||||||
|
|
||||||
let (listener, addr) = transport
|
let (listener, addr) = transport
|
||||||
.listen_on("/ip4/127.0.0.1/tcp/0".parse().unwrap())
|
.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 _ = 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
|
let future = transport
|
||||||
.dial(rx.recv().unwrap())
|
.dial(rx.recv().unwrap())
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "libp2p-yamux"
|
name = "libp2p-yamux"
|
||||||
|
edition = "2018"
|
||||||
description = "Yamux multiplexing protocol for libp2p"
|
description = "Yamux multiplexing protocol for libp2p"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
@ -21,15 +21,9 @@
|
|||||||
//! Implements the Yamux multiplexing protocol for libp2p, see also the
|
//! Implements the Yamux multiplexing protocol for libp2p, see also the
|
||||||
//! [specification](https://github.com/hashicorp/yamux/blob/master/spec.md).
|
//! [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 futures::{future::{self, FutureResult}, prelude::*};
|
||||||
use libp2p_core::{muxing::Shutdown, upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}};
|
use libp2p_core::{muxing::Shutdown, upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}};
|
||||||
|
use log::error;
|
||||||
use std::{io, iter};
|
use std::{io, iter};
|
||||||
use std::io::{Error as IoError};
|
use std::io::{Error as IoError};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user