libp2p-next (#3076)

* Changes for the next libp2p release:

  * Updates to the Kademlia APIs.
  * Updated imports due to the extracted libp2p-swarm crate.
  * ...

Still pending at least the following:

  * rust-libp2p/#1189
  * rust-libp2p/#1191
  * rust-libp2p/#1194

* Use Quorum::One.

The previous choice was apparently arbitrary.

* Use libp2p-0.11 from crates.io. Address feedback.

* Correct imports after merge.
This commit is contained in:
Roman Borschel
2019-07-24 17:32:25 +02:00
committed by Pierre Krieger
parent 5d58d583e3
commit 343f4a2a50
14 changed files with 264 additions and 202 deletions
+108 -98
View File
@@ -1582,33 +1582,34 @@ dependencies = [
[[package]]
name = "libp2p"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core-derive 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-deflate 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-dns 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-floodsub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-identify 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-kad 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-mdns 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-mplex 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-noise 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-ping 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-plaintext 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-ratelimit 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-secio 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-tcp 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-uds 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-wasm-ext 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-websocket 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-yamux 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core-derive 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-deflate 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-dns 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-floodsub 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-identify 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-kad 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-mdns 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-mplex 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-noise 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-ping 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-plaintext 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-ratelimit 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-secio 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-tcp 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-uds 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-wasm-ext 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-websocket 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-yamux 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1619,7 +1620,7 @@ dependencies = [
[[package]]
name = "libp2p-core"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"asn1_der 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1634,7 +1635,7 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1654,7 +1655,7 @@ dependencies = [
[[package]]
name = "libp2p-core-derive"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1663,30 +1664,29 @@ dependencies = [
[[package]]
name = "libp2p-deflate"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-dns"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-floodsub"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1694,27 +1694,25 @@ dependencies = [
"cuckoofilter 0.3.2 (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.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-identify"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (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.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1726,21 +1724,20 @@ dependencies = [
[[package]]
name = "libp2p-kad"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 4.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bs58 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.2 (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.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1754,13 +1751,14 @@ dependencies = [
[[package]]
name = "libp2p-mdns"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1775,13 +1773,13 @@ dependencies = [
[[package]]
name = "libp2p-mplex"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (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.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1791,14 +1789,14 @@ dependencies = [
[[package]]
name = "libp2p-noise"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1811,18 +1809,16 @@ dependencies = [
[[package]]
name = "libp2p-ping"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1830,23 +1826,23 @@ dependencies = [
[[package]]
name = "libp2p-plaintext"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-ratelimit"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1854,18 +1850,17 @@ dependencies = [
[[package]]
name = "libp2p-secio"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"asn1_der 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"protobuf 2.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1881,16 +1876,29 @@ dependencies = [
"web-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-swarm"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-tcp"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1899,23 +1907,23 @@ dependencies = [
[[package]]
name = "libp2p-uds"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libp2p-wasm-ext"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1924,12 +1932,12 @@ dependencies = [
[[package]]
name = "libp2p-websocket"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"soketto 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1942,11 +1950,11 @@ dependencies = [
[[package]]
name = "libp2p-yamux"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2595,7 +2603,7 @@ dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
"unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2604,10 +2612,11 @@ dependencies = [
[[package]]
name = "parity-multihash"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4368,7 +4377,7 @@ version = "2.0.0"
dependencies = [
"derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4543,7 +4552,7 @@ dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4616,7 +4625,7 @@ name = "substrate-peerset"
version = "2.0.0"
dependencies = [
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4816,7 +4825,7 @@ dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6088,26 +6097,27 @@ dependencies = [
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
"checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff"
"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
"checksum libp2p 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29f6b3be5b0cb89f7a072352e2a3bf86991dce0909624181e9e343db0b558568"
"checksum libp2p-core 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c71c33e59899d57ed0a14272984705561abd71788a2b303598ec57dac32130e8"
"checksum libp2p-core-derive 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e6df0fa6933f4be908cfd8c6d627776aa8c909066ba7ce13b017bfe18b9c92b"
"checksum libp2p-deflate 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "448fe9d2231bc21bb308f394346780666a376274ceaf3380e5c7adf3cdbf5a9c"
"checksum libp2p-dns 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67ec2cea26aaccd4bdf264075d6a499bc635b90cb23419bcc3b1f2f0d135c451"
"checksum libp2p-floodsub 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c39c17f2b7c994106e00ccd71a9941d8574c01bef5f97e36d9a106cbde14fab"
"checksum libp2p-identify 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9455cc0752fd3e3f35e9464598576c54476772eaa927b773f7fdf5686ae51f"
"checksum libp2p-kad 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a1f595983a76012779d6941a9d51fc0b9b95d720315787bf8d73f6672351f6d8"
"checksum libp2p-mdns 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7847e6e13a793d70ee5a5d833ddb13ff277c4c0d4fc65b5bc8543ef37df8cf"
"checksum libp2p-mplex 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "29bd0885dd9154d93a1fa83e06a10aba2f0e3a0bf9eb63233c095141fbfaf525"
"checksum libp2p-noise 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f8e0852efc26bfcba11fcc7c4fb593ed00446c19b6d90db39794a3a7ac48e13"
"checksum libp2p-ping 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3dfda9d329eacf6a8e875c18b5e5317a47b326cb58372f506fff8b6259c8951a"
"checksum libp2p-plaintext 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "86759777e5441725b60c6e78b23933b03a531b45d1f3e7d1fb430df49e0b151c"
"checksum libp2p-ratelimit 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f965ff88fda7b1fff062b18b25d781b86c17ea335a237958220895f3e3ddfdd8"
"checksum libp2p-secio 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df1d980a61a1423518205f6710e692102c94efb8132b5dcc54ffe5dbac621360"
"checksum libp2p-tcp 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24faf4ebb10b805f2e2221540097f764075edd18ca735cab0430a118382888df"
"checksum libp2p-uds 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f57a4942babd03f582a838238093b08f94521f63c8b12889a914be5c3cc170c2"
"checksum libp2p-wasm-ext 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5427b52a8a51460961fadd72bd9fdcd957a2a7706588559423ccb86b58a52a7d"
"checksum libp2p-websocket 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "152dce704e235f47b9460004d7ac09663d43f4ca3cb99ddb8d4e0be54240673e"
"checksum libp2p-yamux 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "907bf1f31d572aa8537595a784f59c86b94162eb03dc51839c32ab4a05a5faad"
"checksum libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18b3404dae1e3110caaae14b2d59bf7254b1e988ed7ed38da59c005bed711e7d"
"checksum libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efa1b75b0b388c0f33bc2e2f5d385885f9ed77f622802895b68ac8397aaef2de"
"checksum libp2p-core-derive 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "954fe45edba727b76196abff0d3894116c32a07e4f8173a8f26caf3484add4c0"
"checksum libp2p-deflate 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56b77964eaf8ba7019df8de2a02f2241ee240011d6de69f4991baf174ad42d2e"
"checksum libp2p-dns 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c2625c6acd4073403f1107e4e038efa02ba5de54de0d08567a2cc338560d63f"
"checksum libp2p-floodsub 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d14e6c61c6e69f291261c8ec001b85a2c6426f2074183a40c337c29ed7939bd1"
"checksum libp2p-identify 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34ba4b8d4e27f4848a6b121604d98818a8527f4269948ba77dfe49f0f1c3dc8f"
"checksum libp2p-kad 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "93384ee24fe137bf3afa8263b8d9e63c6bd6c92aad7cc50949fdba2b90db93a4"
"checksum libp2p-mdns 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd24b59da234647e15c34054158b6853a505301d5888719593e6fcd7841c39d9"
"checksum libp2p-mplex 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b101952e8dfdc5c902f1063cd8bfbb80e735857a16d387033ae8180df578009"
"checksum libp2p-noise 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1dd3313a8216b92e3ae5a24034d6fc35bf9671e9f4ad4b2ce445291852508b77"
"checksum libp2p-ping 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c803a4d21c97e14eb8b5019cc32242e296f1d1835de8664e5464d7dc31f068d"
"checksum libp2p-plaintext 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbac75c9683aa5997887420007ea2cf47ab9b68584b4edfa2b20598c9d509273"
"checksum libp2p-ratelimit 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7abef2e38e9d4bb5036724d325dd0518007e32d73d5171334d4d5355995bb4d8"
"checksum libp2p-secio 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "33c208e7c74c15c72e7092503d6772ed5b2add2155e08234ae10169769e3135c"
"checksum libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8788a19e54240ba632ec0913bb951e7fd744f4e6151b2dc1a8b44d80b2947830"
"checksum libp2p-tcp 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "180543c45126c4eec42f35594e169a8d7c891253bc127297ca7781c05ad8bce6"
"checksum libp2p-uds 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffaf9dfc24beaf7ad5be01a6eabe67842cd02575da68a08ebe11b5a8821fc4a9"
"checksum libp2p-wasm-ext 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "35307568a484cce18eae7516201ecbbfc3fb7e17c7f235d407690aee6adaa046"
"checksum libp2p-websocket 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e6c6d86998e66848f16b65e89896d94fa3825e218d2fc44cbc6b84e8ef97bb9"
"checksum libp2p-yamux 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c03b89d025c7b01c966348e4d618b1ec4b95f3c09749ca9f2b2c98240aabfe6"
"checksum librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b"
"checksum libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "688e8d65e495567c2c35ea0001b26b9debf0b4ea11f8cccc954233b75fc3428a"
"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
@@ -6158,7 +6168,7 @@ dependencies = [
"checksum parity-codec 4.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7902deb39d3b431897f211c1918789938251e67a740f55effd53201e79c0906c"
"checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c"
"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7"
"checksum parity-multihash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eb83358a0c05e52c44d658981fec2d146d3516d1adffd9e553684f8c8e9e8fa5"
"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3"
"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
"checksum parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc"
"checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc"
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
derive_more = "0.14.0"
libp2p = { version = "0.10.0", default-features = false }
libp2p = { version = "0.11.0", default-features = false }
log = "0.4"
primitives = { package = "substrate-primitives", path= "../../primitives" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
+1 -1
View File
@@ -22,7 +22,7 @@ linked_hash_set = "0.1.3"
lru-cache = "0.1.1"
rustc-hex = "2.0"
rand = "0.6"
libp2p = { version = "0.10.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
libp2p = { version = "0.11.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
fork-tree = { path = "../../core/utils/fork-tree" }
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" }
+7 -1
View File
@@ -23,7 +23,7 @@ use crate::protocol::{CustomMessageOutcome, Protocol};
use futures::prelude::*;
use libp2p::NetworkBehaviour;
use libp2p::core::{Multiaddr, PeerId, PublicKey};
use libp2p::core::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess};
use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess};
use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
use libp2p::multihash::Multihash;
use log::warn;
@@ -150,6 +150,12 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> NetworkBehaviourEventPr
for Behaviour<B, S, H> {
fn inject_event(&mut self, out: DiscoveryOut) {
match out {
DiscoveryOut::UnroutablePeer(_peer_id) => {
// Obtaining and reporting listen addresses for unroutable peers back
// to Kademlia is handled by the `Identify` protocol, part of the
// `DebugInfoBehaviour`. See the `NetworkBehaviourEventProcess`
// implementation for `DebugInfoEvent`.
}
DiscoveryOut::Discovered(peer_id) => {
self.substrate.add_discovered_nodes(iter::once(peer_id));
}
@@ -20,8 +20,8 @@ use crate::custom_proto::upgrade::{CustomMessage, RegisteredProtocol};
use fnv::FnvHashMap;
use futures::prelude::*;
use futures03::{compat::Compat, TryFutureExt as _, StreamExt as _, TryStreamExt as _};
use libp2p::core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::core::{Multiaddr, PeerId};
use libp2p::core::{ConnectedPoint, Multiaddr, PeerId};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use log::{debug, error, trace, warn};
use smallvec::SmallVec;
use std::{borrow::Cow, collections::hash_map::Entry, cmp, error, marker::PhantomData, mem, pin::Pin};
@@ -19,13 +19,14 @@ use crate::custom_proto::upgrade::{RegisteredProtocolEvent, RegisteredProtocolSu
use futures::prelude::*;
use futures03::{compat::Compat, TryFutureExt as _};
use futures_timer::Delay;
use libp2p::core::{
ConnectedPoint, PeerId, Endpoint, ProtocolsHandler, ProtocolsHandlerEvent,
protocols_handler::IntoProtocolsHandler,
protocols_handler::KeepAlive,
protocols_handler::ProtocolsHandlerUpgrErr,
protocols_handler::SubstreamProtocol,
upgrade::{InboundUpgrade, OutboundUpgrade}
use libp2p::core::{ConnectedPoint, PeerId, Endpoint};
use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade};
use libp2p::swarm::{
ProtocolsHandler, ProtocolsHandlerEvent,
IntoProtocolsHandler,
KeepAlive,
ProtocolsHandlerUpgrErr,
SubstreamProtocol,
};
use log::{debug, error};
use smallvec::{smallvec, SmallVec};
@@ -17,11 +17,10 @@
#![cfg(test)]
use futures::{future, prelude::*, try_ready};
use libp2p::core::{nodes::Substream, swarm::Swarm};
use libp2p::core::{transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::core::{ProtocolsHandler, protocols_handler::IntoProtocolsHandler};
use libp2p::core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
use libp2p::core::swarm::PollParameters;
use libp2p::core::nodes::Substream;
use libp2p::core::{ConnectedPoint, transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::swarm::{Swarm, ProtocolsHandler, IntoProtocolsHandler};
use libp2p::swarm::{PollParameters, NetworkBehaviour, NetworkBehaviourAction};
use libp2p::{PeerId, Multiaddr, Transport};
use rand::seq::SliceRandom;
use std::{io, time::Duration, time::Instant};
@@ -84,7 +83,7 @@ fn build_nodes<T: CustomMessage + Send + 'static>()
.collect(),
};
let mut swarm = libp2p::core::swarm::Swarm::new(
let mut swarm = Swarm::new(
transport,
behaviour,
keypairs[index].public().into_peer_id()
+3 -4
View File
@@ -18,10 +18,9 @@ use fnv::FnvHashMap;
use futures::prelude::*;
use futures03::{StreamExt as _, TryStreamExt as _};
use libp2p::Multiaddr;
use libp2p::core::{either::EitherOutput, PeerId, PublicKey};
use libp2p::core::protocols_handler::{IntoProtocolsHandler, IntoProtocolsHandlerSelect, ProtocolsHandler};
use libp2p::core::nodes::ConnectedPoint;
use libp2p::core::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::core::{ConnectedPoint, either::EitherOutput, PeerId, PublicKey};
use libp2p::swarm::{IntoProtocolsHandler, IntoProtocolsHandlerSelect, ProtocolsHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::identify::{Identify, IdentifyEvent, protocol::IdentifyInfo};
use libp2p::ping::{Ping, PingConfig, PingEvent, PingSuccess};
use log::{debug, trace, error};
+120 -74
View File
@@ -48,18 +48,21 @@
use futures::prelude::*;
use futures_timer::Delay;
use futures03::{compat::Compat, TryFutureExt as _};
use libp2p::core::{Multiaddr, PeerId, ProtocolsHandler, PublicKey};
use libp2p::core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction};
use libp2p::core::swarm::PollParameters;
use libp2p::core::{ConnectedPoint, Multiaddr, PeerId, PublicKey};
use libp2p::swarm::{ProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::kad::{Kademlia, KademliaEvent, Quorum, Record};
use libp2p::kad::GetClosestPeersError;
use libp2p::kad::record::store::MemoryStore;
#[cfg(not(target_os = "unknown"))]
use libp2p::core::{swarm::toggle::Toggle, nodes::Substream, muxing::StreamMuxerBox};
use libp2p::kad::{GetValueResult, Kademlia, KademliaOut, PutValueResult};
use libp2p::{swarm::toggle::Toggle};
#[cfg(not(target_os = "unknown"))]
use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
#[cfg(not(target_os = "unknown"))]
use libp2p::mdns::{Mdns, MdnsEvent};
use libp2p::multihash::Multihash;
use libp2p::multiaddr::Protocol;
use log::{debug, info, trace, warn};
use std::{cmp, collections::VecDeque, num::NonZeroU8, time::Duration};
use std::{cmp, collections::VecDeque, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite};
/// Implementation of `NetworkBehaviour` that discovers the nodes on the network.
@@ -68,7 +71,7 @@ pub struct DiscoveryBehaviour<TSubstream> {
/// reserved nodes.
user_defined: Vec<(PeerId, Multiaddr)>,
/// Kademlia requests and answers.
kademlia: Kademlia<TSubstream>,
kademlia: Kademlia<TSubstream, MemoryStore>,
/// Discovers nodes on the local network.
#[cfg(not(target_os = "unknown"))]
mdns: Toggle<Mdns<Substream<StreamMuxerBox>>>,
@@ -98,7 +101,9 @@ impl<TSubstream> DiscoveryBehaviour<TSubstream> {
warn!(target: "sub-libp2p", "mDNS is not available on this platform");
}
let mut kademlia = Kademlia::new(local_public_key.clone().into_peer_id());
let local_id = local_public_key.clone().into_peer_id();
let store = MemoryStore::new(local_id.clone());
let mut kademlia = Kademlia::new(local_id.clone(), store);
for (peer_id, addr) in &user_defined {
kademlia.add_address(peer_id, addr.clone());
}
@@ -155,8 +160,7 @@ impl<TSubstream> DiscoveryBehaviour<TSubstream> {
///
/// A corresponding `ValueFound` or `ValueNotFound` event will later be generated.
pub fn get_value(&mut self, key: &Multihash) {
self.kademlia.get_value(key, NonZeroU8::new(10)
.expect("Casting 10 to NonZeroU8 should succeed; qed"));
self.kademlia.get_record(key, Quorum::One)
}
/// Start putting a record into the DHT. Other nodes can later fetch that value with
@@ -164,15 +168,24 @@ impl<TSubstream> DiscoveryBehaviour<TSubstream> {
///
/// A corresponding `ValuePut` or `ValuePutFailed` event will later be generated.
pub fn put_value(&mut self, key: Multihash, value: Vec<u8>) {
self.kademlia.put_value(key, value);
self.kademlia.put_record(Record::new(key, value), Quorum::All);
}
}
/// Event generated by the `DiscoveryBehaviour`.
pub enum DiscoveryOut {
/// We have discovered a node. Can be called multiple times with the same identity.
/// The address of a peer has been added to the Kademlia routing table.
///
/// Can be called multiple times with the same identity.
Discovered(PeerId),
/// A peer connected to this node for whom no listen address is known.
///
/// In order for the peer to be added to the Kademlia routing table, a known
/// listen address must be added via [`DiscoveryBehaviour::add_self_reported_address`],
/// e.g. obtained through the `identify` protocol.
UnroutablePeer(PeerId),
/// The DHT yeided results for the record request, grouped in (key, value) pairs.
ValueFound(Vec<(Multihash, Vec<u8>)>),
@@ -190,7 +203,7 @@ impl<TSubstream> NetworkBehaviour for DiscoveryBehaviour<TSubstream>
where
TSubstream: AsyncRead + AsyncWrite,
{
type ProtocolsHandler = <Kademlia<TSubstream> as NetworkBehaviour>::ProtocolsHandler;
type ProtocolsHandler = <Kademlia<TSubstream, MemoryStore> as NetworkBehaviour>::ProtocolsHandler;
type OutEvent = DiscoveryOut;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
@@ -272,9 +285,11 @@ where
let random_peer_id = PeerId::random();
debug!(target: "sub-libp2p", "Libp2p <= Starting random Kademlia request for \
{:?}", random_peer_id);
self.kademlia.find_node(random_peer_id);
// Reset the `Delay` to the next random.
self.kademlia.get_closest_peers(random_peer_id);
// Schedule the next random query with exponentially increasing delay,
// capped at 60 seconds.
self.next_kad_random_query = Delay::new(self.duration_to_next_kad).compat();
self.duration_to_next_kad = cmp::min(self.duration_to_next_kad * 2,
Duration::from_secs(60));
@@ -290,50 +305,74 @@ where
loop {
match self.kademlia.poll(params) {
Async::NotReady => break,
Async::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => {
match ev {
KademliaOut::Discovered { .. } => {}
KademliaOut::KBucketAdded { peer_id, .. } => {
let ev = DiscoveryOut::Discovered(peer_id);
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
KademliaOut::FindNodeResult { key, closer_peers } => {
trace!(target: "sub-libp2p", "Libp2p => Query for {:?} yielded {:?} results",
key, closer_peers.len());
if closer_peers.is_empty() && self.num_connections != 0 {
warn!(target: "sub-libp2p", "Libp2p => Random Kademlia query has yielded empty \
results");
Async::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => match ev {
KademliaEvent::UnroutablePeer { peer, .. } => {
let ev = DiscoveryOut::UnroutablePeer(peer);
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
KademliaEvent::RoutingUpdated { peer, .. } => {
let ev = DiscoveryOut::Discovered(peer);
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
KademliaEvent::GetClosestPeersResult(res) => {
match res {
Err(GetClosestPeersError::Timeout { key, peers }) => {
warn!(target: "sub-libp2p",
"Libp2p => Query for {:?} timed out with {:?} results",
key, peers.len());
},
Ok(ok) => {
trace!(target: "sub-libp2p",
"Libp2p => Query for {:?} yielded {:?} results",
ok.key, ok.peers.len());
if ok.peers.is_empty() && self.num_connections != 0 {
warn!(target: "sub-libp2p", "Libp2p => Random Kademlia query has yielded empty \
results");
}
}
}
KademliaOut::GetValueResult(res) => {
let ev = match res {
GetValueResult::Found { results } => {
let results = results
.into_iter()
.map(|r| (r.key, r.value))
.collect();
}
KademliaEvent::GetRecordResult(res) => {
let ev = match res {
Ok(ok) => {
let results = ok.records
.into_iter()
.map(|r| (r.key, r.value))
.collect();
DiscoveryOut::ValueFound(results)
}
GetValueResult::NotFound { key, .. } => {
DiscoveryOut::ValueNotFound(key)
}
};
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
DiscoveryOut::ValueFound(results)
}
Err(e) => {
DiscoveryOut::ValueNotFound(e.into_key())
}
};
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
KademliaEvent::PutRecordResult(res) => {
let ev = match res {
Ok(ok) => DiscoveryOut::ValuePut(ok.key),
Err(e) => {
DiscoveryOut::ValuePutFailed(e.into_key())
}
};
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
KademliaEvent::RepublishRecordResult(res) => {
match res {
Ok(ok) => debug!(target: "sub-libp2p",
"Libp2p => Record republished: {:?}",
ok.key),
Err(e) => warn!(target: "sub-libp2p",
"Libp2p => Republishing of record {:?} failed with: {:?}",
e.key(), e)
}
KademliaOut::PutValueResult(res) => {
let ev = match res {
PutValueResult::Ok{ key, .. } => {
DiscoveryOut::ValuePut(key)
}
PutValueResult::Err { key, .. } => {
DiscoveryOut::ValuePutFailed(key)
}
};
return Async::Ready(NetworkBehaviourAction::GenerateEvent(ev));
}
// We never start any other type of query.
KademliaOut::GetProvidersResult { .. } => {}
}
KademliaEvent::Discovered { .. } => {
// We are not interested in these events at the moment.
}
// We never start any other type of query.
e => {
warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e)
}
},
Async::Ready(NetworkBehaviourAction::DialAddress { address }) =>
@@ -384,9 +423,10 @@ mod tests {
use futures::prelude::*;
use libp2p::identity::Keypair;
use libp2p::Multiaddr;
use libp2p::core::{upgrade, Swarm};
use libp2p::core::upgrade;
use libp2p::core::transport::{Transport, MemoryTransport};
use libp2p::core::upgrade::{InboundUpgradeExt, OutboundUpgradeExt};
use libp2p::swarm::Swarm;
use std::collections::HashSet;
use super::{DiscoveryBehaviour, DiscoveryOut};
@@ -428,28 +468,34 @@ mod tests {
.collect::<HashSet<_>>()
}).collect::<Vec<_>>();
let fut = futures::future::poll_fn(move || -> Result<_, ()> {
loop {
let mut keep_polling = false;
let fut = futures::future::poll_fn::<_, (), _>(move || {
'polling: loop {
for swarm_n in 0..swarms.len() {
if let Async::Ready(Some(DiscoveryOut::Discovered(other))) =
swarms[swarm_n].0.poll().unwrap() {
if to_discover[swarm_n].remove(&other) {
keep_polling = true;
// Call `add_self_reported_address` to simulate identify happening.
let addr = swarms.iter()
.find(|s| *Swarm::local_peer_id(&s.0) == other)
.unwrap()
.1.clone();
swarms[swarm_n].0.add_self_reported_address(&other, addr);
match swarms[swarm_n].0.poll().unwrap() {
Async::Ready(Some(e)) => {
match e {
DiscoveryOut::UnroutablePeer(other) => {
// Call `add_self_reported_address` to simulate identify happening.
let addr = swarms.iter().find_map(|(s, a)|
if s.local_peer_id == other {
Some(a.clone())
} else {
None
})
.unwrap();
swarms[swarm_n].0.add_self_reported_address(&other, addr);
},
DiscoveryOut::Discovered(other) => {
to_discover[swarm_n].remove(&other);
}
_ => {}
}
continue 'polling
}
_ => {}
}
}
if !keep_polling {
break;
}
break
}
if to_discover.iter().all(|l| l.is_empty()) {
+1 -1
View File
@@ -204,7 +204,7 @@ pub use on_demand_layer::{OnDemand, RemoteResponse};
#[doc(hidden)]
pub use runtime_primitives::traits::Block as BlockT;
use libp2p::core::nodes::ConnectedPoint;
use libp2p::core::ConnectedPoint;
use serde::{Deserialize, Serialize};
use slog_derive::SerdeValue;
use std::{collections::{HashMap, HashSet}, time::Duration};
+3 -3
View File
@@ -19,9 +19,9 @@ use crate::custom_proto::{CustomProto, CustomProtoOut};
use futures::prelude::*;
use futures03::{StreamExt as _, TryStreamExt as _};
use libp2p::{Multiaddr, PeerId};
use libp2p::core::swarm::{ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
use libp2p::core::protocols_handler::{ProtocolsHandler, IntoProtocolsHandler};
use libp2p::core::{ConnectedPoint, nodes::Substream, muxing::StreamMuxerBox};
use libp2p::swarm::{ProtocolsHandler, IntoProtocolsHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use primitives::storage::StorageKey;
use consensus::{import_queue::IncomingBlock, import_queue::Origin, BlockOrigin};
use runtime_primitives::{generic::BlockId, ConsensusEngineId, Justification};
+3 -2
View File
@@ -32,8 +32,9 @@ use consensus::import_queue::{ImportQueue, Link};
use consensus::import_queue::{BlockImportResult, BlockImportError};
use futures::{prelude::*, sync::mpsc};
use log::{warn, error, info};
use libp2p::core::{swarm::NetworkBehaviour, transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::{PeerId, Multiaddr, multihash::Multihash};
use libp2p::core::{transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::swarm::NetworkBehaviour;
use parking_lot::Mutex;
use peerset::PeersetHandle;
use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId};
@@ -675,7 +676,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> Future for Ne
}
/// The libp2p swarm, customized for our needs.
type Swarm<B, S, H> = libp2p::core::Swarm<
type Swarm<B, S, H> = libp2p::swarm::Swarm<
Boxed<(PeerId, StreamMuxerBox), io::Error>,
Behaviour<B, S, H>
>;
+1 -1
View File
@@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
futures-preview = "0.3.0-alpha.17"
libp2p = { version = "0.10.0", default-features = false }
libp2p = { version = "0.11.0", default-features = false }
linked-hash-map = "0.5"
log = "0.4"
lru-cache = "0.1.2"
+1 -1
View File
@@ -11,7 +11,7 @@ parking_lot = "0.8.0"
futures01 = { package = "futures", version = "0.1" }
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
futures-timer = "0.2.1"
libp2p = { version = "0.10.0", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.11.0", default-features = false, features = ["libp2p-websocket"] }
log = "0.4"
rand = "0.6"
serde = { version = "1.0.81", features = ["derive"] }