tokio p2p init
This commit is contained in:
parent
f80947fbfd
commit
2f90b65454
|
@ -5,10 +5,9 @@ dependencies = [
|
|||
"bitcrypto 0.1.0",
|
||||
"chain 0.1.0",
|
||||
"keys 0.1.0",
|
||||
"net 0.1.0",
|
||||
"p2p 0.1.0",
|
||||
"primitives 0.1.0",
|
||||
"script 0.1.0",
|
||||
"serialization 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -33,11 +32,21 @@ dependencies = [
|
|||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "chain"
|
||||
version = "0.1.0"
|
||||
|
@ -60,6 +69,14 @@ dependencies = [
|
|||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.35"
|
||||
|
@ -92,11 +109,48 @@ name = "lazy_static"
|
|||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.0"
|
||||
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)",
|
||||
"lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.6.0 (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)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miow"
|
||||
version = "0.1.3"
|
||||
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)",
|
||||
"net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "net"
|
||||
version = "0.1.0"
|
||||
|
@ -107,6 +161,31 @@ dependencies = [
|
|||
"serialization 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "net2"
|
||||
version = "0.2.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nodrop"
|
||||
version = "0.1.8"
|
||||
|
@ -120,6 +199,17 @@ name = "odds"
|
|||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "p2p"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"net 0.1.0",
|
||||
"primitives 0.1.0",
|
||||
"serialization 0.1.0",
|
||||
"tokio-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "primitives"
|
||||
version = "0.1.0"
|
||||
|
@ -152,6 +242,19 @@ name = "rustc-serialize"
|
|||
version = "0.3.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "script"
|
||||
version = "0.1.0"
|
||||
|
@ -163,6 +266,11 @@ dependencies = [
|
|||
"serialization 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serialization"
|
||||
version = "0.1.0"
|
||||
|
@ -171,6 +279,11 @@ dependencies = [
|
|||
"primitives 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.35"
|
||||
|
@ -181,6 +294,23 @@ dependencies = [
|
|||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-core"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"futures 0.1.1 (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.0 (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)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
|
@ -191,3 +321,12 @@ name = "winapi-build"
|
|||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ws2_32-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ authors = ["debris <marek.kotewicz@gmail.com>"]
|
|||
bitcrypto = { path = "crypto" }
|
||||
chain = { path = "chain" }
|
||||
keys = { path = "keys" }
|
||||
net = { path = "net" }
|
||||
p2p = { path = "p2p" }
|
||||
primitives = { path = "primitives" }
|
||||
script = { path = "script" }
|
||||
serialization = { path = "serialization" }
|
||||
|
|
|
@ -4,6 +4,6 @@ extern crate primitives;
|
|||
extern crate serialization as ser;
|
||||
|
||||
mod common;
|
||||
mod messages;
|
||||
pub mod messages;
|
||||
|
||||
pub use primitives::{hash, bytes};
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "p2p"
|
||||
version = "0.1.0"
|
||||
authors = ["debris <marek.kotewicz@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
tokio-core = "0.1"
|
||||
futures = "0.1"
|
||||
|
||||
primitives = { path = "../primitives" }
|
||||
serialization = { path = "../serialization" }
|
||||
net = { path = "../net" }
|
|
@ -0,0 +1,21 @@
|
|||
use std::io;
|
||||
use ser::{Error as ReaderError};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Io(io::Error),
|
||||
Data(ReaderError),
|
||||
}
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
fn from(e: io::Error) -> Self {
|
||||
Error::Io(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ReaderError> for Error {
|
||||
fn from(e: ReaderError) -> Self {
|
||||
Error::Data(e)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
mod error;
|
||||
mod read_header;
|
||||
|
||||
pub use self::error::Error;
|
||||
pub use self::read_header::{read_header, ReadHeader};
|
|
@ -0,0 +1,31 @@
|
|||
use std::io;
|
||||
use futures::{Future, Poll, Async};
|
||||
use tokio_core::io::{ReadExact, read_exact};
|
||||
use ser::deserialize;
|
||||
use net::messages::MessageHeader;
|
||||
use io::Error;
|
||||
|
||||
pub fn read_header<A>(a: A) -> ReadHeader<A> where A: io::Read {
|
||||
ReadHeader {
|
||||
reader: read_exact(a, [0u8; 24]),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ReadHeader<A> {
|
||||
reader: ReadExact<A, [u8; 24]>,
|
||||
}
|
||||
|
||||
impl<A> Future for ReadHeader<A> where A: io::Read {
|
||||
type Item = (A, MessageHeader);
|
||||
type Error = Error;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
match try_nb!(self.reader.poll()) {
|
||||
Async::Ready((read, data)) => {
|
||||
let header: MessageHeader = try!(deserialize(&data));
|
||||
Ok(Async::Ready((read, header)))
|
||||
},
|
||||
_ => Ok(Async::NotReady),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#[macro_use]
|
||||
extern crate tokio_core;
|
||||
extern crate futures;
|
||||
extern crate primitives;
|
||||
extern crate serialization as ser;
|
||||
extern crate net;
|
||||
|
||||
pub mod io;
|
||||
|
||||
pub use primitives::bytes;
|
|
@ -13,7 +13,5 @@
|
|||
extern crate bitcrypto as crypto;
|
||||
extern crate chain;
|
||||
extern crate keys;
|
||||
extern crate net;
|
||||
extern crate primitives;
|
||||
extern crate script;
|
||||
extern crate serialization as ser;
|
||||
|
|
154
tools/graph.dot
154
tools/graph.dot
|
@ -3,75 +3,129 @@ digraph dependencies {
|
|||
N1[label="bitcrypto",shape=box];
|
||||
N2[label="chain",shape=box];
|
||||
N3[label="keys",shape=box];
|
||||
N4[label="net",shape=box];
|
||||
N4[label="p2p",shape=box];
|
||||
N5[label="primitives",shape=box];
|
||||
N6[label="script",shape=box];
|
||||
N7[label="serialization",shape=box];
|
||||
N8[label="arrayvec",shape=box];
|
||||
N9[label="nodrop",shape=box];
|
||||
N10[label="odds",shape=box];
|
||||
N11[label="base58",shape=box];
|
||||
N12[label="rust-crypto",shape=box];
|
||||
N7[label="arrayvec",shape=box];
|
||||
N8[label="nodrop",shape=box];
|
||||
N9[label="odds",shape=box];
|
||||
N10[label="base58",shape=box];
|
||||
N11[label="rust-crypto",shape=box];
|
||||
N12[label="bitflags",shape=box];
|
||||
N13[label="byteorder",shape=box];
|
||||
N14[label="rustc-serialize",shape=box];
|
||||
N15[label="eth-secp256k1",shape=box];
|
||||
N16[label="gcc",shape=box];
|
||||
N17[label="libc",shape=box];
|
||||
N18[label="rand",shape=box];
|
||||
N19[label="kernel32-sys",shape=box];
|
||||
N20[label="winapi",shape=box];
|
||||
N21[label="winapi-build",shape=box];
|
||||
N22[label="lazy_static",shape=box];
|
||||
N23[label="time",shape=box];
|
||||
N14[label="cfg-if",shape=box];
|
||||
N15[label="rustc-serialize",shape=box];
|
||||
N16[label="serialization",shape=box];
|
||||
N17[label="eth-secp256k1",shape=box];
|
||||
N18[label="gcc",shape=box];
|
||||
N19[label="libc",shape=box];
|
||||
N20[label="rand",shape=box];
|
||||
N21[label="futures",shape=box];
|
||||
N22[label="log",shape=box];
|
||||
N23[label="kernel32-sys",shape=box];
|
||||
N24[label="winapi",shape=box];
|
||||
N25[label="winapi-build",shape=box];
|
||||
N26[label="lazy_static",shape=box];
|
||||
N27[label="lazycell",shape=box];
|
||||
N28[label="mio",shape=box];
|
||||
N29[label="miow",shape=box];
|
||||
N30[label="net2",shape=box];
|
||||
N31[label="nix",shape=box];
|
||||
N32[label="slab",shape=box];
|
||||
N33[label="ws2_32-sys",shape=box];
|
||||
N34[label="net",shape=box];
|
||||
N35[label="rustc_version",shape=box];
|
||||
N36[label="semver",shape=box];
|
||||
N37[label="void",shape=box];
|
||||
N38[label="tokio-core",shape=box];
|
||||
N39[label="time",shape=box];
|
||||
N40[label="scoped-tls",shape=box];
|
||||
N0 -> N1[label="",style=dashed];
|
||||
N0 -> N2[label="",style=dashed];
|
||||
N0 -> N3[label="",style=dashed];
|
||||
N0 -> N4[label="",style=dashed];
|
||||
N0 -> N5[label="",style=dashed];
|
||||
N0 -> N6[label="",style=dashed];
|
||||
N0 -> N7[label="",style=dashed];
|
||||
N1 -> N5[label="",style=dashed];
|
||||
N1 -> N12[label="",style=dashed];
|
||||
N1 -> N11[label="",style=dashed];
|
||||
N2 -> N1[label="",style=dashed];
|
||||
N2 -> N5[label="",style=dashed];
|
||||
N2 -> N7[label="",style=dashed];
|
||||
N2 -> N14[label="",style=dashed];
|
||||
N2 -> N15[label="",style=dashed];
|
||||
N2 -> N16[label="",style=dashed];
|
||||
N3 -> N1[label="",style=dashed];
|
||||
N3 -> N5[label="",style=dashed];
|
||||
N3 -> N11[label="",style=dashed];
|
||||
N3 -> N14[label="",style=dashed];
|
||||
N3 -> N10[label="",style=dashed];
|
||||
N3 -> N15[label="",style=dashed];
|
||||
N3 -> N18[label="",style=dashed];
|
||||
N3 -> N22[label="",style=dashed];
|
||||
N4 -> N1[label="",style=dashed];
|
||||
N3 -> N17[label="",style=dashed];
|
||||
N3 -> N20[label="",style=dashed];
|
||||
N3 -> N26[label="",style=dashed];
|
||||
N4 -> N5[label="",style=dashed];
|
||||
N4 -> N7[label="",style=dashed];
|
||||
N4 -> N13[label="",style=dashed];
|
||||
N5 -> N14[label="",style=dashed];
|
||||
N4 -> N16[label="",style=dashed];
|
||||
N4 -> N21[label="",style=dashed];
|
||||
N4 -> N34[label="",style=dashed];
|
||||
N4 -> N38[label="",style=dashed];
|
||||
N5 -> N15[label="",style=dashed];
|
||||
N6 -> N1[label="",style=dashed];
|
||||
N6 -> N2[label="",style=dashed];
|
||||
N6 -> N3[label="",style=dashed];
|
||||
N6 -> N5[label="",style=dashed];
|
||||
N6 -> N7[label="",style=dashed];
|
||||
N7 -> N5[label="",style=dashed];
|
||||
N7 -> N13[label="",style=dashed];
|
||||
N6 -> N16[label="",style=dashed];
|
||||
N7 -> N8[label=""];
|
||||
N7 -> N9[label=""];
|
||||
N8 -> N9[label=""];
|
||||
N8 -> N10[label=""];
|
||||
N9 -> N10[label=""];
|
||||
N12 -> N14[label="",style=dashed];
|
||||
N12 -> N16[label="",style=dashed];
|
||||
N12 -> N17[label="",style=dashed];
|
||||
N12 -> N18[label="",style=dashed];
|
||||
N12 -> N23[label="",style=dashed];
|
||||
N15 -> N8[label="",style=dashed];
|
||||
N15 -> N14[label="",style=dashed];
|
||||
N15 -> N16[label="",style=dashed];
|
||||
N15 -> N17[label="",style=dashed];
|
||||
N15 -> N18[label="",style=dashed];
|
||||
N18 -> N17[label="",style=dashed];
|
||||
N19 -> N20[label="",style=dashed];
|
||||
N19 -> N21[label=""];
|
||||
N23 -> N17[label="",style=dashed];
|
||||
N23 -> N19[label="",style=dashed];
|
||||
N23 -> N20[label="",style=dashed];
|
||||
N11 -> N15[label="",style=dashed];
|
||||
N11 -> N18[label="",style=dashed];
|
||||
N11 -> N19[label="",style=dashed];
|
||||
N11 -> N20[label="",style=dashed];
|
||||
N11 -> N39[label="",style=dashed];
|
||||
N16 -> N5[label="",style=dashed];
|
||||
N16 -> N13[label="",style=dashed];
|
||||
N17 -> N7[label="",style=dashed];
|
||||
N17 -> N15[label="",style=dashed];
|
||||
N17 -> N18[label="",style=dashed];
|
||||
N17 -> N19[label="",style=dashed];
|
||||
N17 -> N20[label="",style=dashed];
|
||||
N20 -> N19[label="",style=dashed];
|
||||
N21 -> N22[label="",style=dashed];
|
||||
N23 -> N24[label="",style=dashed];
|
||||
N23 -> N25[label=""];
|
||||
N28 -> N19[label="",style=dashed];
|
||||
N28 -> N22[label="",style=dashed];
|
||||
N28 -> N23[label="",style=dashed];
|
||||
N28 -> N24[label="",style=dashed];
|
||||
N28 -> N27[label=""];
|
||||
N28 -> N29[label=""];
|
||||
N28 -> N30[label=""];
|
||||
N28 -> N31[label=""];
|
||||
N28 -> N32[label="",style=dashed];
|
||||
N29 -> N23[label=""];
|
||||
N29 -> N24[label=""];
|
||||
N29 -> N30[label=""];
|
||||
N29 -> N33[label=""];
|
||||
N30 -> N14[label=""];
|
||||
N30 -> N19[label=""];
|
||||
N30 -> N23[label=""];
|
||||
N30 -> N24[label=""];
|
||||
N30 -> N33[label=""];
|
||||
N31 -> N12[label=""];
|
||||
N31 -> N14[label=""];
|
||||
N31 -> N19[label=""];
|
||||
N31 -> N35[label=""];
|
||||
N31 -> N36[label=""];
|
||||
N31 -> N37[label=""];
|
||||
N33 -> N24[label=""];
|
||||
N33 -> N25[label=""];
|
||||
N34 -> N1[label="",style=dashed];
|
||||
N34 -> N5[label="",style=dashed];
|
||||
N34 -> N13[label="",style=dashed];
|
||||
N34 -> N16[label="",style=dashed];
|
||||
N35 -> N36[label=""];
|
||||
N38 -> N21[label="",style=dashed];
|
||||
N38 -> N22[label="",style=dashed];
|
||||
N38 -> N28[label="",style=dashed];
|
||||
N38 -> N32[label="",style=dashed];
|
||||
N38 -> N40[label="",style=dashed];
|
||||
N39 -> N19[label="",style=dashed];
|
||||
N39 -> N23[label="",style=dashed];
|
||||
N39 -> N24[label="",style=dashed];
|
||||
}
|
||||
|
|
BIN
tools/graph.png
BIN
tools/graph.png
Binary file not shown.
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 173 KiB |
Loading…
Reference in New Issue