From 7e2cb6d09c7b77090eb25af5aea039a2dac34c3a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 7 Sep 2018 18:56:38 +0200 Subject: [PATCH] Improvements to the Kademlia system (#688) --- Cargo.lock | 285 +++++++----------- substrate/network-libp2p/Cargo.toml | 2 +- substrate/network-libp2p/src/network_state.rs | 30 +- substrate/network-libp2p/src/service.rs | 59 ++-- substrate/network-libp2p/src/topology.rs | 74 +++-- 5 files changed, 204 insertions(+), 246 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37ca7481b6ef4..d202a84d2278c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,34 +1,3 @@ -[[package]] -name = "aes-ctr" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aes-soft 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "aesni 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ctr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aes-soft" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "aesni" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "aho-corasick" version = "0.6.4" @@ -214,14 +183,6 @@ dependencies = [ "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "block-cipher-trait" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bs58" version = "0.2.0" @@ -414,15 +375,6 @@ name = "crunchy" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "ctr" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ctrlc" version = "1.1.1" @@ -436,7 +388,7 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", @@ -1139,27 +1091,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-uds 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-dns 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-floodsub 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-identify 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-kad 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-mplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-ratelimit 0.1.1 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-relay 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-transport-timeout 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-uds 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-yamux 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1169,20 +1121,20 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "multihash 0.8.1-pre (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "smallvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1190,12 +1142,12 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "tokio-dns-unofficial 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1203,16 +1155,16 @@ dependencies = [ [[package]] name = "libp2p-floodsub" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1224,15 +1176,15 @@ dependencies = [ [[package]] name = "libp2p-identify" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1243,20 +1195,20 @@ dependencies = [ [[package]] name = "libp2p-kad" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 4.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-identify 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1270,12 +1222,12 @@ dependencies = [ [[package]] name = "libp2p-mplex" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1286,13 +1238,13 @@ dependencies = [ [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1301,14 +1253,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1318,11 +1270,11 @@ dependencies = [ [[package]] name = "libp2p-ratelimit" version = "0.1.1" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "aio-limited 0.1.0 (git+https://github.com/paritytech/aio-limited.git)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1331,14 +1283,14 @@ dependencies = [ [[package]] name = "libp2p-relay" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1349,34 +1301,32 @@ dependencies = [ [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ - "aes-ctr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "asn1_der 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ctr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "twofish 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "tk-listen 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1385,10 +1335,10 @@ dependencies = [ [[package]] name = "libp2p-transport-timeout" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1396,25 +1346,25 @@ dependencies = [ [[package]] name = "libp2p-uds" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "tokio-uds 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", + "rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.3 (git+https://github.com/tomaka/rust-websocket?branch=send)", @@ -1423,11 +1373,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1572,19 +1522,19 @@ dependencies = [ [[package]] name = "multiaddr" version = "0.3.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "multihash 0.8.1-pre (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "multihash" version = "0.8.1-pre" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1594,7 +1544,7 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1676,11 +1626,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "opaque-debug" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "openssl" version = "0.9.24" @@ -2147,7 +2092,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5#8ac9b65e669ebbd9deeffa9d4566c95f631cfed5" +source = "git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346#304e9c72c88bc97824f2734dc19d1b5f4556d346" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2362,14 +2307,6 @@ name = "stdweb" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stream-cipher" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "strsim" version = "0.7.0" @@ -2624,7 +2561,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)", + "libp2p 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3516,16 +3453,6 @@ name = "try-lock" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "twofish" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "twox-hash" version = "1.1.0" @@ -3829,9 +3756,6 @@ dependencies = [ ] [metadata] -"checksum aes-ctr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f65958ff3692041c36fc009261ccd63f24cd8e0dc1164266f068c2387e8b4e4f" -"checksum aes-soft 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67cc03b0a090a05cb01e96998a01905d7ceedce1bc23b756c0bb7faa0682ccb1" -"checksum aesni 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6810b7fb9f2bb4f76f05ac1c170b8dde285b6308955dc3afd89710268c958d9e" "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum aio-limited 0.1.0 (git+https://github.com/paritytech/aio-limited.git)" = "" "checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" @@ -3855,7 +3779,6 @@ dependencies = [ "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" -"checksum block-cipher-trait 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "370424437b9459f3dfd68428ed9376ddfe03d8b70ede29cc533b3557df186ab4" "checksum bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6ea4851598d7433fbdba71fa2509d9b0df68124b9c0effe7588f5149692d9f" "checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" "checksum byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96c8b41881888cc08af32d47ac4edd52bc7fa27fef774be47a92443756451304" @@ -3881,9 +3804,8 @@ dependencies = [ "checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum ctr 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50ac3add446ec1f8fe3dc007cd838f5b22bbf33186394feac505451ecc43c018" "checksum ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)" = "" -"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" +"checksum datastore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3cae2388d706b52f2f2f9afe280f9d768be36544bd71d1b8120cb34ea6450b55" @@ -3949,23 +3871,23 @@ dependencies = [ "checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" -"checksum libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-uds 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" +"checksum libp2p 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-core 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-dns 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-floodsub 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-identify 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-kad 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-mplex 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-ratelimit 0.1.1 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-relay 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-transport-timeout 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-uds 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum libp2p-yamux 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ceb20f39ff7ae42f3ff9795f3986b1daad821caaa1e1732a0944103a5a1a66" "checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54" @@ -3982,9 +3904,9 @@ dependencies = [ "checksum mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "6d771e3ef92d58a8da8df7d6976bfca9371ed1de6619d9d5a5ce5b1f29b85bfe" "checksum mio-uds 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "84c7b5caa3a118a6e34dbac36504503b1e8dc5835e833306b9d6af0e05929f79" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" +"checksum multiaddr 0.3.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum multihash 0.8.1-pre (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" @@ -3994,7 +3916,6 @@ dependencies = [ "checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" -"checksum opaque-debug 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d620c9c26834b34f039489ac0dfdb12c7ac15ccaf818350a64c9b5334a452ad7" "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" "checksum openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)" = "d8abc04833dcedef24221a91852931df2f63e3369ae003134e70aff3645775cc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" @@ -4048,7 +3969,7 @@ dependencies = [ "checksum rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b03280c2813907a030785570c577fb27d3deec8da4c18566751ade94de0ace" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=8ac9b65e669ebbd9deeffa9d4566c95f631cfed5)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=304e9c72c88bc97824f2734dc19d1b5f4556d346)" = "" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade" @@ -4078,7 +3999,6 @@ dependencies = [ "checksum smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "26df3bb03ca5eac2e64192b723d51f56c1b1e0860e7c766281f4598f181acdc8" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" -"checksum stream-cipher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "30dc6118470d69ce0fdcf7e6f95e95853f7f4f72f80d835d4519577c323814ab" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum subtle 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc7f6353c2ee5407358d063a14cccc1630804527090a6fb5a9489ce4924280fb" "checksum syn 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfd71b2be5a58ee30a6f8ea355ba8290d397131c00dfa55c3d34e6e13db5101" @@ -4117,7 +4037,6 @@ dependencies = [ "checksum transaction-pool 1.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fdb8870eea404a57e2f62056ac45067a53a6207fd31866122356481d3c2e1a30" "checksum triehash 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3da77dc2c88bac48769c53f2c7675d99d522a7fc8130da3fadf29d7c6f94c9ac" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" -"checksum twofish 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1eef327f05b0d0ec1b9d7d119d8f4d9f602ceee37e0540aff8071e8e66c2e22e" "checksum twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "475352206e7a290c5fccc27624a163e8d0d115f7bb60ca18a64fc9ce056d7435" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" diff --git a/substrate/network-libp2p/Cargo.toml b/substrate/network-libp2p/Cargo.toml index 392f6c984d87f..b002fa82e969a 100644 --- a/substrate/network-libp2p/Cargo.toml +++ b/substrate/network-libp2p/Cargo.toml @@ -11,7 +11,7 @@ bytes = "0.4" error-chain = { version = "0.12", default-features = false } fnv = "1.0" futures = "0.1" -libp2p = { git = "https://github.com/tomaka/libp2p-rs", rev = "8ac9b65e669ebbd9deeffa9d4566c95f631cfed5", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] } +libp2p = { git = "https://github.com/libp2p/rust-libp2p", rev = "304e9c72c88bc97824f2734dc19d1b5f4556d346", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] } ethcore-io = { git = "https://github.com/paritytech/parity.git" } ethkey = { git = "https://github.com/paritytech/parity.git" } ethereum-types = "0.3" diff --git a/substrate/network-libp2p/src/network_state.rs b/substrate/network-libp2p/src/network_state.rs index 6226dedc347fb..e06735f647fc5 100644 --- a/substrate/network-libp2p/src/network_state.rs +++ b/substrate/network-libp2p/src/network_state.rs @@ -253,17 +253,6 @@ impl NetworkState { (list, change) } - /// Returns all the IDs of the peers on the network we have knowledge of. - /// - /// This includes peers we are not connected to. - pub fn known_peers(&self) -> Vec { - let topology = self.topology.read(); - // Note: I have no idea why, but fusing the two lines below fails the - // borrow check - let out: Vec<_> = topology.peers().cloned().collect(); - out - } - /// Returns true if we are connected to any peer at all. pub fn has_connected_peer(&self) -> bool { !self.connections.read().peer_by_nodeid.is_empty() @@ -350,16 +339,21 @@ impl NetworkState { /// Adds an address discovered by Kademlia. /// Note that we don't have to be connected to a peer to add an address. - pub fn add_kad_discovered_addr(&self, node_id: &PeerId, addr: Multiaddr) { - self.topology.write().add_kademlia_discovered_addr(node_id, addr) + /// If `connectable` is `true`, that means we have a hint from a remote that this node can be + /// connected to. + pub fn add_kad_discovered_addr(&self, node_id: &PeerId, addr: Multiaddr, connectable: bool) { + self.topology.write().add_kademlia_discovered_addr(node_id, addr, connectable) } /// Returns the known multiaddresses of a peer. - pub fn addrs_of_peer(&self, node_id: &PeerId) -> Vec { + /// + /// The boolean associated to each address indicates whether we're connected to it. + pub fn addrs_of_peer(&self, node_id: &PeerId) -> Vec<(Multiaddr, bool)> { let topology = self.topology.read(); // Note: I have no idea why, but fusing the two lines below fails the // borrow check - let out: Vec = topology.addrs_of_peer(node_id).cloned().collect(); + let out: Vec<_> = topology + .addrs_of_peer(node_id).map(|(a, c)| (a.clone(), c)).collect(); out } @@ -424,12 +418,6 @@ impl NetworkState { } } - /// Returns true if we are connected to the given node. - pub fn has_connection(&self, node_id: &PeerId) -> bool { - let connections = self.connections.read(); - connections.peer_by_nodeid.contains_key(node_id) - } - /// Reports that we tried to connect to the given address but failed. /// /// This decreases the chance this address will be tried again in the future. diff --git a/substrate/network-libp2p/src/service.rs b/substrate/network-libp2p/src/service.rs index 00f522faeedf9..4e82973893240 100644 --- a/substrate/network-libp2p/src/service.rs +++ b/substrate/network-libp2p/src/service.rs @@ -33,6 +33,7 @@ use libp2p::transport_timeout::TransportTimeout; use {PacketId, SessionInfo, TimerToken}; use rand; use std::io::{Error as IoError, ErrorKind as IoErrorKind}; +use std::iter; use std::net::SocketAddr; use std::sync::Arc; use std::sync::mpsc as sync_mpsc; @@ -119,7 +120,7 @@ impl NetworkService { local_peer_id: local_peer_id.clone(), kbuckets_timeout: Duration::from_secs(600), request_timeout: Duration::from_secs(10), - known_initial_peers: network_state.known_peers().into_iter(), + known_initial_peers: iter::empty(), }); // Channel we use to signal success or failure of the bg thread @@ -703,8 +704,11 @@ fn handle_kademlia_connection( .and_then(move |(req, rest)| { shared.kad_system.update_kbuckets(node_id); match req { - Some(KadIncomingRequest::FindNode { searched, responder }) => - responder.respond(build_kademlia_response(&shared, &searched)), + Some(KadIncomingRequest::FindNode { searched, responder }) => { + let resp = build_kademlia_response(&shared, &searched); + trace!(target: "sub-libp2p", "Responding to Kad {:?} with {:?}", searched, resp); + responder.respond(resp) + }, Some(KadIncomingRequest::PingPong) => (), None => return Ok(future::Loop::Break(())) } @@ -734,19 +738,25 @@ fn build_kademlia_response( connection_ty: KadConnectionType::Connected, } } else { - let addrs = shared.network_state.addrs_of_peer(&who); - let connec_ty = if shared.network_state.has_connection(&who) { - // TODO: this only checks connections with substrate ; but what - // if we're connected through Kademlia only? - KadConnectionType::Connected - } else { - KadConnectionType::NotConnected - }; + let mut addrs = shared.network_state.addrs_of_peer(&who); + let connected = addrs.iter().any(|&(_, conn)| conn); + // The Kademlia protocol of libp2p doesn't allow specifying which address is valid + // and which is outdated, therefore in order to stay honest towards the network + // we only report the addresses we're connected to if we're connected to any. + if connected { + addrs = addrs.into_iter() + .filter_map(|(a, c)| if c { Some((a, c)) } else { None }) + .collect(); + } KadPeer { node_id: who.clone(), - multiaddrs: addrs, - connection_ty: connec_ty, + multiaddrs: addrs.into_iter().map(|(a, _)| a).collect(), + connection_ty: if connected { + KadConnectionType::Connected + } else { + KadConnectionType::NotConnected + }, } } }) @@ -980,10 +990,21 @@ fn perform_kademlia_query( }) .filter_map(move |event| match event { - KadQueryEvent::NewKnownMultiaddrs(peers) => { - for (peer, addrs) in peers { - for addr in addrs { - shared.network_state.add_kad_discovered_addr(&peer, addr); + KadQueryEvent::PeersReported(peers) => { + for peer in peers { + let connected = match peer.connection_ty { + KadConnectionType::NotConnected => false, + KadConnectionType::Connected => true, + KadConnectionType::CanConnect => true, + KadConnectionType::CannotConnect => continue, + }; + + for addr in peer.multiaddrs { + shared.network_state.add_kad_discovered_addr( + &peer.node_id, + addr, + connected + ); } } None @@ -1167,7 +1188,7 @@ fn obtain_kad_connection( Ok((kad, addr)) }) .and_then(move |(unique_connec, addr)| { - unique_connec.dial(&swarm_controller, &addr, transport.clone()) + unique_connec.dial(&swarm_controller, &addr.0, transport.clone()) }) .then(|result| -> Result<_, ()> { Ok(result.ok()) }) .filter_map(|result| result) @@ -1215,7 +1236,7 @@ fn process_identify_info( for addr in info.listen_addrs.iter() { if let Some(node_id) = shared.network_state.node_id_from_index(node_index) { - shared.network_state.add_kad_discovered_addr(&node_id, addr.clone()); + shared.network_state.add_kad_discovered_addr(&node_id, addr.clone(), true); } } } diff --git a/substrate/network-libp2p/src/topology.rs b/substrate/network-libp2p/src/topology.rs index dc7a32cad9c06..d36eb07624bca 100644 --- a/substrate/network-libp2p/src/topology.rs +++ b/substrate/network-libp2p/src/topology.rs @@ -27,7 +27,12 @@ use std::time::{Duration, Instant, SystemTime}; const CONNEC_DURATION_PER_SCORE: Duration = Duration::from_secs(10); /// Maximum value for the score. const MAX_SCORE: u32 = 100; -/// Initial score that a node discovered through Kademlia receives. +/// When we successfully connect to a node, raises its score to the given minimum value. +const CONNECTED_MINIMUM_SCORE: u32 = 20; +/// Initial score that a node discovered through Kademlia receives, where we have a hint that the +/// node is reachable. +const KADEMLIA_DISCOVERY_INITIAL_SCORE_CONNECTABLE: u32 = 15; +/// Initial score that a node discovered through Kademlia receives, without any hint. const KADEMLIA_DISCOVERY_INITIAL_SCORE: u32 = 10; /// Score adjustement when we fail to connect to an address. const SCORE_DIFF_ON_FAILED_TO_CONNECT: i32 = -1; @@ -112,23 +117,17 @@ impl NetTopology { let now_systime = SystemTime::now(); self.store.retain(|_, peer| { peer.addrs.retain(|a| { - a.expires > now_systime + a.expires > now_systime || a.is_connected() }); !peer.addrs.is_empty() }); } - /// Returns a list of all the known peers. - pub fn peers(&self) -> impl Iterator { - self.store.keys() - } - /// Returns the known potential addresses of a peer, ordered by score. /// - /// If we're already connected to that peer, the address(es) we're connected with will be at - /// the top of the list. + /// The boolean associated to each address indicates whether we're connected to it. // TODO: filter out backed off ones? - pub fn addrs_of_peer(&self, peer: &PeerId) -> impl Iterator { + pub fn addrs_of_peer(&self, peer: &PeerId) -> impl Iterator { let peer = if let Some(peer) = self.store.get(peer) { peer } else { @@ -140,14 +139,14 @@ impl NetTopology { let mut list = peer.addrs.iter().filter_map(move |addr| { let (score, connected) = addr.score_and_is_connected(); if (addr.expires >= now && score > 0) || connected { - Some((score, &addr.addr)) + Some((score, connected, &addr.addr)) } else { None } }).collect::>(); list.sort_by(|a, b| a.0.cmp(&b.0)); // TODO: meh, optimize - let l = list.into_iter().map(|(_, addr)| addr).collect::>(); + let l = list.into_iter().map(|(_, connec, addr)| (addr, connec)).collect::>(); l.into_iter() } @@ -195,7 +194,7 @@ impl NetTopology { let mut found = false; peer.addrs.retain(|a| { - if a.expires < now_systime { + if a.expires < now_systime && !a.is_connected() { return false; } if a.addr == addr { @@ -222,7 +221,15 @@ impl NetTopology { /// Adds an address discovered through the Kademlia DHT. /// /// This address is not necessarily valid and should expire after a TTL. - pub fn add_kademlia_discovered_addr(&mut self, peer_id: &PeerId, addr: Multiaddr) { + /// + /// If `connectable` is true, that means we have some sort of hint that this node can + /// be reached. + pub fn add_kademlia_discovered_addr( + &mut self, + peer_id: &PeerId, + addr: Multiaddr, + connectable: bool + ) { let now_systime = SystemTime::now(); let now = Instant::now(); @@ -230,7 +237,7 @@ impl NetTopology { let mut found = false; peer.addrs.retain(|a| { - if a.expires < now_systime { + if a.expires < now_systime && !a.is_connected() { return false; } if a.addr == addr { @@ -240,7 +247,20 @@ impl NetTopology { }); if !found { - trace!(target: "sub-libp2p", "Peer store: adding address {} for {:?}", addr, peer_id); + trace!( + target: "sub-libp2p", + "Peer store: adding address {} for {:?} (connectable hint: {:?})", + addr, + peer_id, + connectable + ); + + let initial_score = if connectable { + KADEMLIA_DISCOVERY_INITIAL_SCORE_CONNECTABLE + } else { + KADEMLIA_DISCOVERY_INITIAL_SCORE + }; + peer.addrs.push(Addr { addr, expires: now_systime + KADEMLIA_DISCOVERY_EXPIRATION, @@ -248,7 +268,7 @@ impl NetTopology { next_back_off: FIRST_CONNECT_FAIL_BACKOFF, score: Mutex::new(AddrScore { connected_since: None, - score: KADEMLIA_DISCOVERY_INITIAL_SCORE, + score: initial_score, latest_score_update: now, }), }); @@ -269,7 +289,7 @@ impl NetTopology { for (peer_in_store, info_in_store) in self.store.iter_mut() { if peer == peer_in_store { if let Some(addr) = info_in_store.addrs.iter_mut().find(|a| &a.addr == addr) { - addr.connected_now(); + addr.connected_now(CONNECTED_MINIMUM_SCORE); addr.back_off_until = now; addr.next_back_off = FIRST_CONNECT_FAIL_BACKOFF; continue; @@ -284,7 +304,7 @@ impl NetTopology { score: Mutex::new(AddrScore { connected_since: Some(now), latest_score_update: now, - score: KADEMLIA_DISCOVERY_INITIAL_SCORE + score: CONNECTED_MINIMUM_SCORE, }), }); @@ -394,12 +414,16 @@ struct AddrScore { } impl Addr { - /// Sets the addr to connected. - fn connected_now(&self) { + /// Sets the addr to connected. If the score is lower than the given value, raises it to this + /// value. + fn connected_now(&self, raise_to_min: u32) { let mut score = self.score.lock(); let now = Instant::now(); Addr::flush(&mut score, now); score.connected_since = Some(now); + if score.score < raise_to_min { + score.score = raise_to_min; + } } /// Applies a modification to the score. @@ -425,6 +449,12 @@ impl Addr { } } + /// Returns true if we are connected to this addr. + fn is_connected(&self) -> bool { + let score = self.score.lock(); + score.connected_since.is_some() + } + /// Returns the score, and true if we are connected to this addr. fn score_and_is_connected(&self) -> (u32, bool) { let mut score = self.score.lock(); @@ -612,7 +642,7 @@ fn serialize(out: W, map: &FnvHashMap) -> Result<(), let peer = peer.to_base58(); let info = SerializedPeerInfo { addrs: info.addrs.iter() - .filter(|a| a.expires > now) + .filter(|a| a.expires > now || a.is_connected()) .map(Into::into) .collect(), };