Merge pull request #384 from paritytech/mioup

updated mio to 0.6.6, use tokio_io::io instead of deprecated tokio_core::io
This commit is contained in:
Svyatoslav Nikolsky 2017-03-27 08:17:20 +03:00 committed by GitHub
commit db1c35a087
14 changed files with 79 additions and 42 deletions

44
Cargo.lock generated
View File

@ -209,7 +209,7 @@ dependencies = [
"ethcore-devtools 1.3.0",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"primitives 0.1.0",
"rocksdb 0.4.5 (git+https://github.com/ethcore/rust-rocksdb)",
"serialization 0.1.0",
@ -551,7 +551,7 @@ dependencies = [
[[package]]
name = "mio"
version = "0.6.5"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -559,7 +559,7 @@ dependencies = [
"lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -578,7 +578,7 @@ dependencies = [
[[package]]
name = "miow"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -677,8 +677,11 @@ dependencies = [
[[package]]
name = "owning_ref"
version = "0.2.4"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "p2p"
@ -693,20 +696,21 @@ dependencies = [
"message 0.1.0",
"network 0.1.0",
"ns-dns-tokio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"primitives 0.1.0",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serialization 0.1.0",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot"
version = "0.3.8"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -987,6 +991,11 @@ name = "spmc"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "stable_deref_trait"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "strsim"
version = "0.6.0"
@ -1020,7 +1029,7 @@ dependencies = [
"murmur3 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"network 0.1.0",
"p2p 0.1.0",
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"primitives 0.1.0",
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"script 0.1.0",
@ -1105,15 +1114,15 @@ dependencies = [
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-io"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1271,9 +1280,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
"checksum mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5c93a4bd787ddc6e7833c519b73a50883deb5863d76d9b71eb8216fb7f94e66"
"checksum mio 0.6.1 (git+https://github.com/ethcore/mio.git)" = "<none>"
"checksum mio 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aa30e3753079b08ce3d75cf3b44783e36fe0e1f64065f65c1d894d1688fb2580"
"checksum mio 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f27d38f824a0d267d55b29b171e9e99269a53812e385fa75c1fe700ae254a6a4"
"checksum miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3e690c5df6b2f60acd45d56378981e827ff8295562fc8d34f573deb267a59cd1"
"checksum miow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3a78d2605eb97302c10cf944b8d96b0a2a890c52957caf92fcd1f24f69049579"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum murmur3 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ece7fe85164ffce69891c581b6b035a3c2f66dd3459f299d43d5efff90663e22"
"checksum net2 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)" = "18b9642ad6222faf5ce46f6966f59b71b9775ad5758c9e09fcf0a6c8061972b4"
"checksum nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d95c5fa8b641c10ad0b8887454ebaafa3c92b5cd5350f8fc693adafd178e7b"
@ -1283,8 +1292,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a18c392466409c50b87369414a2680c93e739aedeb498eb2bff7d7eb569744e2"
"checksum odds 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "c3df9b730298cea3a1c3faa90b7e2f9df3a9c400d0936d6015e6165734eefcba"
"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
"checksum owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d52571ddcb42e9c900c901a18d8d67e393df723fcd51dd59c5b1a85d0acb6cc"
"checksum parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fa12d706797d42551663426a45e2db2e0364bd1dbf6aeada87e89c5f981f43e9"
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
"checksum parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aebb68eebde2c99f89592d925288600fde220177e46b5c9a91ca218d245aeedf"
"checksum parking_lot_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1b97670a2ffadce7c397fb80a3d687c4f3060140b885621ef1653d0e5d5068"
"checksum quick-error 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0aad603e8d7fb67da22dbdf1f4b826ce8829e406124109e73cf1b2454b93a71c"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
@ -1310,6 +1319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23"
"checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410"
"checksum spmc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "93bdab61c1a413e591c4d17388ffa859eaff2df27f1e13a5ec8b716700605adf"
"checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum syn 0.11.9 (registry+https://github.com/rust-lang/crates.io-index)" = "480c834701caba3548aa991e54677281be3a5414a9d09ddbdf4ed74a569a9d19"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
@ -1319,7 +1329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
"checksum tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "99e958104a67877907c1454386d5482fe8e965a55d60be834a15a44328e7dc76"
"checksum tokio-io 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6a278fde45f1be68e44995227d426aaa4841e0980bb0a21b981092f28c3c8473"
"checksum tokio-io 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "48f55df1341bb92281f229a6030bc2abffde2c7a44c6d6b802b7687dd8be0775"
"checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764"
"checksum unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a078ebdd62c0e71a709c3d53d2af693fe09fe93fbff8344aebe289b78f9032"
"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff"

View File

@ -11,7 +11,7 @@ primitives = { path = "../primitives" }
byteorder = "1.0"
chain = { path = "../chain" }
serialization = { path = "../serialization" }
parking_lot = "0.3"
parking_lot = "0.4"
test-data = { path = "../test-data" }
bit-vec = "0.4"
log = "0.3"

View File

@ -4,8 +4,9 @@ version = "0.1.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
[dependencies]
tokio-core = "0.1"
parking_lot = "0.3"
tokio-core = "0.1.6"
tokio-io = "0.1.1"
parking_lot = "0.4"
futures = "0.1"
futures-cpupool = "0.1"
time = "0.1"

View File

@ -1,11 +1,12 @@
use std::{io, cmp};
use futures::{Future, Poll, Async};
use tokio_io::{AsyncRead, AsyncWrite};
use message::{Message, MessageResult, Error};
use message::types::{Version, Verack};
use network::Magic;
use io::{write_message, WriteMessage, ReadMessage, read_message};
pub fn handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> Handshake<A> where A: io::Write + io::Read {
pub fn handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> Handshake<A> where A: AsyncWrite + AsyncRead {
Handshake {
version: version.version(),
state: HandshakeState::SendVersion(write_message(a, version_message(magic, version))),
@ -14,7 +15,7 @@ pub fn handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> H
}
}
pub fn accept_handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> AcceptHandshake<A> where A: io::Write + io::Read {
pub fn accept_handshake<A>(a: A, magic: Magic, version: Version, min_version: u32) -> AcceptHandshake<A> where A: AsyncWrite + AsyncRead {
AcceptHandshake {
version: version.version(),
state: AcceptHandshakeState::ReceiveVersion {
@ -84,7 +85,7 @@ pub struct AcceptHandshake<A> {
min_version: u32,
}
impl<A> Future for Handshake<A> where A: io::Read + io::Write {
impl<A> Future for Handshake<A> where A: AsyncRead + AsyncWrite {
type Item = (A, MessageResult<HandshakeResult>);
type Error = io::Error;
@ -135,7 +136,7 @@ impl<A> Future for Handshake<A> where A: io::Read + io::Write {
}
}
impl<A> Future for AcceptHandshake<A> where A: io::Read + io::Write {
impl<A> Future for AcceptHandshake<A> where A: AsyncRead + AsyncWrite {
type Item = (A, MessageResult<HandshakeResult>);
type Error = io::Error;
@ -196,7 +197,8 @@ impl<A> Future for AcceptHandshake<A> where A: io::Read + io::Write {
#[cfg(test)]
mod tests {
use std::io;
use futures::Future;
use futures::{Future, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
use bytes::Bytes;
use ser::Stream;
use network::Magic;
@ -216,6 +218,8 @@ mod tests {
}
}
impl AsyncRead for TestIo {}
impl io::Write for TestIo {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
io::Write::write(&mut self.write, buf)
@ -226,6 +230,12 @@ mod tests {
}
}
impl AsyncWrite for TestIo {
fn shutdown(&mut self) -> Poll<(), io::Error> {
Ok(().into())
}
}
fn local_version() -> Version {
Version::V70001(V0 {
version: 70001,

View File

@ -1,13 +1,14 @@
use std::io;
use futures::{Future, Poll, Async};
use tokio_core::io::{read_exact, ReadExact};
use tokio_io::io::{read_exact, ReadExact};
use tokio_io::AsyncRead;
use crypto::checksum;
use network::Magic;
use message::{Error, MessageHeader, MessageResult, Command};
use bytes::Bytes;
use io::{read_header, ReadHeader};
pub fn read_any_message<A>(a: A, magic: Magic) -> ReadAnyMessage<A> where A: io::Read {
pub fn read_any_message<A>(a: A, magic: Magic) -> ReadAnyMessage<A> where A: AsyncRead {
ReadAnyMessage {
state: ReadAnyMessageState::ReadHeader(read_header(a, magic)),
}
@ -26,7 +27,7 @@ pub struct ReadAnyMessage<A> {
state: ReadAnyMessageState<A>,
}
impl<A> Future for ReadAnyMessage<A> where A: io::Read {
impl<A> Future for ReadAnyMessage<A> where A: AsyncRead {
type Item = MessageResult<(Command, Bytes)>;
type Error = io::Error;

View File

@ -1,10 +1,11 @@
use std::io;
use futures::{Future, Poll, Async};
use tokio_core::io::{ReadExact, read_exact};
use tokio_io::AsyncRead;
use tokio_io::io::{ReadExact, read_exact};
use message::{MessageHeader, MessageResult};
use network::Magic;
pub fn read_header<A>(a: A, magic: Magic) -> ReadHeader<A> where A: io::Read {
pub fn read_header<A>(a: A, magic: Magic) -> ReadHeader<A> where A: AsyncRead {
ReadHeader {
reader: read_exact(a, [0u8; 24]),
magic: magic,
@ -16,7 +17,7 @@ pub struct ReadHeader<A> {
magic: Magic,
}
impl<A> Future for ReadHeader<A> where A: io::Read {
impl<A> Future for ReadHeader<A> where A: AsyncRead {
type Item = (A, MessageResult<MessageHeader>);
type Error = io::Error;

View File

@ -1,12 +1,13 @@
use std::io;
use std::marker::PhantomData;
use futures::{Poll, Future, Async};
use tokio_io::AsyncRead;
use network::Magic;
use message::{MessageResult, Error, Payload};
use io::{read_header, ReadHeader, read_payload, ReadPayload};
pub fn read_message<M, A>(a: A, magic: Magic, version: u32) -> ReadMessage<M, A>
where A: io::Read, M: Payload {
where A: AsyncRead, M: Payload {
ReadMessage {
state: ReadMessageState::ReadHeader {
version: version,
@ -32,7 +33,7 @@ pub struct ReadMessage<M, A> {
message_type: PhantomData<M>,
}
impl<M, A> Future for ReadMessage<M, A> where A: io::Read, M: Payload {
impl<M, A> Future for ReadMessage<M, A> where A: AsyncRead, M: Payload {
type Item = (A, MessageResult<M>);
type Error = io::Error;

View File

@ -1,14 +1,15 @@
use std::io;
use std::marker::PhantomData;
use futures::{Poll, Future};
use tokio_core::io::{read_exact, ReadExact};
use tokio_io::AsyncRead;
use tokio_io::io::{read_exact, ReadExact};
use bytes::Bytes;
use hash::H32;
use crypto::checksum;
use message::{Error, MessageResult, Payload, deserialize_payload};
pub fn read_payload<M, A>(a: A, version: u32, len: usize, checksum: H32) -> ReadPayload<M, A>
where A: io::Read, M: Payload {
where A: AsyncRead, M: Payload {
ReadPayload {
reader: read_exact(a, Bytes::new_with_len(len)),
version: version,
@ -24,7 +25,7 @@ pub struct ReadPayload<M, A> {
payload_type: PhantomData<M>,
}
impl<M, A> Future for ReadPayload<M, A> where A: io::Read, M: Payload {
impl<M, A> Future for ReadPayload<M, A> where A: AsyncRead, M: Payload {
type Item = (A, MessageResult<M>);
type Error = io::Error;

View File

@ -1,6 +1,8 @@
use std::sync::Arc;
use std::net::Shutdown;
use std::io::{Read, Write, Error};
use futures::Poll;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_core::net::TcpStream;
pub struct SharedTcpStream {
@ -32,6 +34,14 @@ impl Read for SharedTcpStream {
}
}
impl AsyncRead for SharedTcpStream {}
impl AsyncWrite for SharedTcpStream {
fn shutdown(&mut self) -> Poll<(), Error> {
self.io.shutdown(Shutdown::Both).map(Into::into)
}
}
impl Write for SharedTcpStream {
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
Write::write(&mut (&*self.io as &TcpStream), buf)

View File

@ -1,9 +1,10 @@
use std::io;
use futures::{Future, Poll};
use tokio_core::io::{WriteAll, write_all};
use tokio_io::AsyncWrite;
use tokio_io::io::{WriteAll, write_all};
use message::Message;
pub fn write_message<M, A>(a: A, message: Message<M>) -> WriteMessage<M, A> where A: io::Write {
pub fn write_message<M, A>(a: A, message: Message<M>) -> WriteMessage<M, A> where A: AsyncWrite {
WriteMessage {
future: write_all(a, message),
}
@ -13,7 +14,7 @@ pub struct WriteMessage<M, A> {
future: WriteAll<A, Message<M>>,
}
impl<M, A> Future for WriteMessage<M, A> where A: io::Write {
impl<M, A> Future for WriteMessage<M, A> where A: AsyncWrite {
type Item = (A, Message<M>);
type Error = io::Error;

View File

@ -4,6 +4,7 @@ extern crate futures_cpupool;
extern crate rand;
extern crate time;
extern crate tokio_core;
extern crate tokio_io;
extern crate parking_lot;
#[macro_use]
extern crate log;

View File

@ -1,4 +1,4 @@
use tokio_core::io::{write_all, WriteAll};
use tokio_io::io::{write_all, WriteAll};
use session::Session;
use io::{SharedTcpStream, read_any_message, ReadAnyMessage};
use util::PeerInfo;

View File

@ -5,7 +5,7 @@ use parking_lot::RwLock;
use futures::{Future, finished, failed, BoxFuture};
use futures::stream::Stream;
use futures_cpupool::CpuPool;
use tokio_core::io::IoFuture;
use tokio_io::IoFuture;
use tokio_core::net::{TcpListener, TcpStream};
use tokio_core::reactor::{Handle, Remote, Timeout, Interval};
use abstract_ns::Resolver;

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Ethcore <admin@ethcore.io>"]
[dependencies]
parking_lot = "0.3"
parking_lot = "0.4"
log = "0.3"
time = "0.1"
futures = "0.1"