improved connect in main.rs
This commit is contained in:
parent
876c589f5c
commit
742e9a6fff
|
@ -3,13 +3,11 @@ name = "pbtc"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitcrypto 0.1.0",
|
||||
"chain 0.1.0",
|
||||
"clap 2.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"keys 0.1.0",
|
||||
"message 0.1.0",
|
||||
"p2p 0.1.0",
|
||||
"primitives 0.1.0",
|
||||
"script 0.1.0",
|
||||
"tokio-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
|
@ -11,11 +11,9 @@ tokio-core = "0.1"
|
|||
futures = "0.1"
|
||||
|
||||
bitcrypto = { path = "crypto" }
|
||||
chain = { path = "chain" }
|
||||
keys = { path = "keys" }
|
||||
message = { path = "message" }
|
||||
p2p = { path = "p2p" }
|
||||
primitives = { path = "primitives" }
|
||||
script = { path = "script" }
|
||||
|
||||
[[bin]]
|
||||
|
|
19
pbtc/main.rs
19
pbtc/main.rs
|
@ -6,17 +6,17 @@ extern crate tokio_core;
|
|||
extern crate futures;
|
||||
|
||||
extern crate bitcrypto as crypto;
|
||||
extern crate chain;
|
||||
extern crate keys;
|
||||
extern crate primitives;
|
||||
extern crate script;
|
||||
extern crate message;
|
||||
extern crate p2p;
|
||||
|
||||
mod config;
|
||||
|
||||
use futures::stream::Stream;
|
||||
use std::thread;
|
||||
use std::net::SocketAddr;
|
||||
use futures::Future;
|
||||
use futures::stream::Stream;
|
||||
use p2p::net::{Config as P2PConfig, connect, listen};
|
||||
|
||||
pub fn event_loop() -> tokio_core::reactor::Core {
|
||||
|
@ -48,8 +48,17 @@ fn run() -> Result<(), String> {
|
|||
};
|
||||
|
||||
if let Some(ip) = cfg.connect {
|
||||
let c = connect(&SocketAddr::new(ip, cfg.magic.port()), &handle, &p2p_cfg);
|
||||
let connection = try!(el.run(c).map_err(|_| format!("Connect to {} failed", ip)));
|
||||
let connection = connect(&SocketAddr::new(ip, cfg.magic.port()), &handle, &p2p_cfg);
|
||||
thread::spawn(move || {
|
||||
match connection.wait() {
|
||||
Ok(connection) => {
|
||||
println!("Connected to ip {}", ip);
|
||||
},
|
||||
Err(err) => {
|
||||
println!("Connection failed {:?}", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let listen = try!(listen(&handle, p2p_cfg).map_err(|_| "Cannot start listening".to_owned()));
|
||||
|
|
147
tools/graph.dot
147
tools/graph.dot
|
@ -1,25 +1,25 @@
|
|||
digraph dependencies {
|
||||
N0[label="pbtc",shape=box];
|
||||
N1[label="bitcrypto",shape=box];
|
||||
N2[label="chain",shape=box];
|
||||
N3[label="clap",shape=box];
|
||||
N4[label="futures",shape=box];
|
||||
N5[label="keys",shape=box];
|
||||
N6[label="message",shape=box];
|
||||
N7[label="p2p",shape=box];
|
||||
N8[label="primitives",shape=box];
|
||||
N9[label="script",shape=box];
|
||||
N10[label="tokio-core",shape=box];
|
||||
N11[label="ansi_term",shape=box];
|
||||
N12[label="arrayvec",shape=box];
|
||||
N13[label="nodrop",shape=box];
|
||||
N14[label="odds",shape=box];
|
||||
N15[label="base58",shape=box];
|
||||
N16[label="rust-crypto",shape=box];
|
||||
N17[label="bitflags v0.4.0",shape=box];
|
||||
N18[label="bitflags v0.7.0",shape=box];
|
||||
N19[label="byteorder",shape=box];
|
||||
N20[label="cfg-if",shape=box];
|
||||
N2[label="clap",shape=box];
|
||||
N3[label="futures",shape=box];
|
||||
N4[label="keys",shape=box];
|
||||
N5[label="message",shape=box];
|
||||
N6[label="p2p",shape=box];
|
||||
N7[label="script",shape=box];
|
||||
N8[label="tokio-core",shape=box];
|
||||
N9[label="ansi_term",shape=box];
|
||||
N10[label="arrayvec",shape=box];
|
||||
N11[label="nodrop",shape=box];
|
||||
N12[label="odds",shape=box];
|
||||
N13[label="base58",shape=box];
|
||||
N14[label="primitives",shape=box];
|
||||
N15[label="rust-crypto",shape=box];
|
||||
N16[label="bitflags v0.4.0",shape=box];
|
||||
N17[label="bitflags v0.7.0",shape=box];
|
||||
N18[label="byteorder",shape=box];
|
||||
N19[label="cfg-if",shape=box];
|
||||
N20[label="chain",shape=box];
|
||||
N21[label="rustc-serialize",shape=box];
|
||||
N22[label="serialization",shape=box];
|
||||
N23[label="libc",shape=box];
|
||||
|
@ -57,68 +57,67 @@ digraph dependencies {
|
|||
N0 -> N6[label="",style=dashed];
|
||||
N0 -> N7[label="",style=dashed];
|
||||
N0 -> N8[label="",style=dashed];
|
||||
N0 -> N9[label="",style=dashed];
|
||||
N0 -> N10[label="",style=dashed];
|
||||
N1 -> N8[label="",style=dashed];
|
||||
N1 -> N16[label="",style=dashed];
|
||||
N2 -> N1[label="",style=dashed];
|
||||
N2 -> N8[label="",style=dashed];
|
||||
N2 -> N21[label="",style=dashed];
|
||||
N2 -> N22[label="",style=dashed];
|
||||
N3 -> N11[label="",style=dashed];
|
||||
N3 -> N18[label="",style=dashed];
|
||||
N3 -> N23[label="",style=dashed];
|
||||
N3 -> N24[label="",style=dashed];
|
||||
N3 -> N25[label="",style=dashed];
|
||||
N3 -> N26[label="",style=dashed];
|
||||
N3 -> N27[label="",style=dashed];
|
||||
N3 -> N28[label="",style=dashed];
|
||||
N3 -> N29[label="",style=dashed];
|
||||
N4 -> N33[label="",style=dashed];
|
||||
N1 -> N14[label="",style=dashed];
|
||||
N1 -> N15[label="",style=dashed];
|
||||
N2 -> N9[label="",style=dashed];
|
||||
N2 -> N17[label="",style=dashed];
|
||||
N2 -> N23[label="",style=dashed];
|
||||
N2 -> N24[label="",style=dashed];
|
||||
N2 -> N25[label="",style=dashed];
|
||||
N2 -> N26[label="",style=dashed];
|
||||
N2 -> N27[label="",style=dashed];
|
||||
N2 -> N28[label="",style=dashed];
|
||||
N2 -> N29[label="",style=dashed];
|
||||
N3 -> N33[label="",style=dashed];
|
||||
N4 -> N1[label="",style=dashed];
|
||||
N4 -> N13[label="",style=dashed];
|
||||
N4 -> N14[label="",style=dashed];
|
||||
N4 -> N21[label="",style=dashed];
|
||||
N4 -> N30[label="",style=dashed];
|
||||
N4 -> N32[label="",style=dashed];
|
||||
N4 -> N37[label="",style=dashed];
|
||||
N5 -> N1[label="",style=dashed];
|
||||
N5 -> N8[label="",style=dashed];
|
||||
N5 -> N15[label="",style=dashed];
|
||||
N5 -> N21[label="",style=dashed];
|
||||
N5 -> N30[label="",style=dashed];
|
||||
N5 -> N32[label="",style=dashed];
|
||||
N5 -> N37[label="",style=dashed];
|
||||
N5 -> N14[label="",style=dashed];
|
||||
N5 -> N18[label="",style=dashed];
|
||||
N5 -> N20[label="",style=dashed];
|
||||
N5 -> N22[label="",style=dashed];
|
||||
N6 -> N1[label="",style=dashed];
|
||||
N6 -> N3[label="",style=dashed];
|
||||
N6 -> N5[label="",style=dashed];
|
||||
N6 -> N8[label="",style=dashed];
|
||||
N6 -> N19[label="",style=dashed];
|
||||
N6 -> N14[label="",style=dashed];
|
||||
N6 -> N22[label="",style=dashed];
|
||||
N6 -> N32[label="",style=dashed];
|
||||
N6 -> N48[label="",style=dashed];
|
||||
N7 -> N1[label="",style=dashed];
|
||||
N7 -> N4[label="",style=dashed];
|
||||
N7 -> N6[label="",style=dashed];
|
||||
N7 -> N8[label="",style=dashed];
|
||||
N7 -> N10[label="",style=dashed];
|
||||
N7 -> N14[label="",style=dashed];
|
||||
N7 -> N20[label="",style=dashed];
|
||||
N7 -> N22[label="",style=dashed];
|
||||
N7 -> N32[label="",style=dashed];
|
||||
N7 -> N48[label="",style=dashed];
|
||||
N8 -> N21[label="",style=dashed];
|
||||
N9 -> N1[label="",style=dashed];
|
||||
N9 -> N2[label="",style=dashed];
|
||||
N9 -> N5[label="",style=dashed];
|
||||
N9 -> N8[label="",style=dashed];
|
||||
N9 -> N22[label="",style=dashed];
|
||||
N10 -> N4[label="",style=dashed];
|
||||
N10 -> N33[label="",style=dashed];
|
||||
N10 -> N39[label="",style=dashed];
|
||||
N10 -> N43[label="",style=dashed];
|
||||
N10 -> N49[label="",style=dashed];
|
||||
N12 -> N13[label=""];
|
||||
N12 -> N14[label=""];
|
||||
N13 -> N14[label=""];
|
||||
N16 -> N21[label="",style=dashed];
|
||||
N16 -> N23[label="",style=dashed];
|
||||
N16 -> N31[label="",style=dashed];
|
||||
N16 -> N32[label="",style=dashed];
|
||||
N16 -> N48[label="",style=dashed];
|
||||
N22 -> N8[label="",style=dashed];
|
||||
N22 -> N19[label="",style=dashed];
|
||||
N8 -> N3[label="",style=dashed];
|
||||
N8 -> N33[label="",style=dashed];
|
||||
N8 -> N39[label="",style=dashed];
|
||||
N8 -> N43[label="",style=dashed];
|
||||
N8 -> N49[label="",style=dashed];
|
||||
N10 -> N11[label=""];
|
||||
N10 -> N12[label=""];
|
||||
N11 -> N12[label=""];
|
||||
N14 -> N21[label="",style=dashed];
|
||||
N15 -> N21[label="",style=dashed];
|
||||
N15 -> N23[label="",style=dashed];
|
||||
N15 -> N31[label="",style=dashed];
|
||||
N15 -> N32[label="",style=dashed];
|
||||
N15 -> N48[label="",style=dashed];
|
||||
N20 -> N1[label="",style=dashed];
|
||||
N20 -> N14[label="",style=dashed];
|
||||
N20 -> N21[label="",style=dashed];
|
||||
N20 -> N22[label="",style=dashed];
|
||||
N22 -> N14[label="",style=dashed];
|
||||
N22 -> N18[label="",style=dashed];
|
||||
N25 -> N23[label="",style=dashed];
|
||||
N25 -> N34[label="",style=dashed];
|
||||
N25 -> N35[label="",style=dashed];
|
||||
N30 -> N12[label="",style=dashed];
|
||||
N30 -> N10[label="",style=dashed];
|
||||
N30 -> N21[label="",style=dashed];
|
||||
N30 -> N23[label="",style=dashed];
|
||||
N30 -> N31[label="",style=dashed];
|
||||
|
@ -139,13 +138,13 @@ digraph dependencies {
|
|||
N40 -> N35[label="",style=dashed];
|
||||
N40 -> N41[label="",style=dashed];
|
||||
N40 -> N44[label="",style=dashed];
|
||||
N41 -> N20[label="",style=dashed];
|
||||
N41 -> N19[label="",style=dashed];
|
||||
N41 -> N23[label="",style=dashed];
|
||||
N41 -> N34[label="",style=dashed];
|
||||
N41 -> N35[label="",style=dashed];
|
||||
N41 -> N44[label="",style=dashed];
|
||||
N42 -> N17[label="",style=dashed];
|
||||
N42 -> N20[label="",style=dashed];
|
||||
N42 -> N16[label="",style=dashed];
|
||||
N42 -> N19[label="",style=dashed];
|
||||
N42 -> N23[label="",style=dashed];
|
||||
N42 -> N45[label="",style=dashed];
|
||||
N42 -> N46[label="",style=dashed];
|
||||
|
|
BIN
tools/graph.png
BIN
tools/graph.png
Binary file not shown.
Before Width: | Height: | Size: 261 KiB After Width: | Height: | Size: 268 KiB |
Loading…
Reference in New Issue