Libp2p update (#1482)

Updates to latest libp2p master. 

This now has native noise support. 

This PR
- Removes secio support
- Prioritises mplex over yamux
This commit is contained in:
Age Manning 2020-08-08 02:17:32 +00:00
parent 1d5d3e3ea7
commit a1f9769040
3 changed files with 98 additions and 241 deletions

271
Cargo.lock generated
View File

@ -86,33 +86,21 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7001367fde4c768a19d1029f0a8be5abd9308e1119846d5bd9ad26297b8faf5"
dependencies = [
"aes-soft 0.4.0",
"aesni 0.7.0",
"aes-soft",
"aesni",
"block-cipher",
]
[[package]]
name = "aes-ctr"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee"
dependencies = [
"aes-soft 0.3.3",
"aesni 0.6.0",
"ctr 0.3.2",
"stream-cipher 0.3.2",
]
[[package]]
name = "aes-ctr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e60aeefd2a0243bd53a42e92444e039f67c3d7f0382c9813577696e7c10bf3"
dependencies = [
"aes-soft 0.4.0",
"aesni 0.7.0",
"ctr 0.4.0",
"stream-cipher 0.4.1",
"aes-soft",
"aesni",
"ctr",
"stream-cipher",
]
[[package]]
@ -128,17 +116,6 @@ dependencies = [
"subtle 2.2.3",
]
[[package]]
name = "aes-soft"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d"
dependencies = [
"block-cipher-trait",
"byteorder",
"opaque-debug 0.2.3",
]
[[package]]
name = "aes-soft"
version = "0.4.0"
@ -150,17 +127,6 @@ dependencies = [
"opaque-debug 0.2.3",
]
[[package]]
name = "aesni"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100"
dependencies = [
"block-cipher-trait",
"opaque-debug 0.2.3",
"stream-cipher 0.3.2",
]
[[package]]
name = "aesni"
version = "0.7.0"
@ -169,7 +135,7 @@ checksum = "d050d39b0b7688b3a3254394c3e30a9d66c41dcf9b05b0e2dbdc623f6505d264"
dependencies = [
"block-cipher",
"opaque-debug 0.2.3",
"stream-cipher 0.4.1",
"stream-cipher",
]
[[package]]
@ -524,15 +490,6 @@ dependencies = [
"generic-array 0.14.3",
]
[[package]]
name = "block-cipher-trait"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774"
dependencies = [
"generic-array 0.12.3",
]
[[package]]
name = "block-padding"
version = "0.1.5"
@ -709,7 +666,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "086c0f07ac275808b7bf9a39f2fd013aae1498be83632814c8c4e0bd53f2dc58"
dependencies = [
"stream-cipher 0.4.1",
"stream-cipher",
"zeroize",
]
@ -722,7 +679,7 @@ dependencies = [
"aead",
"chacha20",
"poly1305",
"stream-cipher 0.4.1",
"stream-cipher",
"zeroize",
]
@ -1080,23 +1037,13 @@ dependencies = [
"memchr",
]
[[package]]
name = "ctr"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736"
dependencies = [
"block-cipher-trait",
"stream-cipher 0.3.2",
]
[[package]]
name = "ctr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3592740fd55aaf61dd72df96756bd0d11e6037b89dcf30ae2e1895b267692be"
dependencies = [
"stream-cipher 0.4.1",
"stream-cipher",
]
[[package]]
@ -1260,7 +1207,7 @@ dependencies = [
"hex 0.4.2",
"hkdf",
"lazy_static",
"libp2p-core 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p-core 0.20.1",
"libsecp256k1",
"log 0.4.11",
"lru_time_cache",
@ -1508,7 +1455,7 @@ dependencies = [
name = "eth2_keystore"
version = "0.1.0"
dependencies = [
"aes-ctr 0.4.0",
"aes-ctr",
"bls",
"eth2_key_derivation",
"eth2_ssz",
@ -2576,7 +2523,7 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
[[package]]
name = "lcli"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"bls",
"clap",
@ -2659,66 +2606,32 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "libp2p"
version = "0.22.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.23.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"atomic",
"bytes 0.5.6",
"futures 0.3.5",
"lazy_static",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"libp2p-core-derive",
"libp2p-dns",
"libp2p-gossipsub",
"libp2p-identify",
"libp2p-mplex",
"libp2p-noise",
"libp2p-secio",
"libp2p-swarm",
"libp2p-tcp",
"libp2p-websocket",
"libp2p-yamux",
"multihash",
"parity-multiaddr 0.9.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"parity-multiaddr 0.9.1 (git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef)",
"parking_lot 0.10.2",
"pin-project",
"smallvec 1.4.1",
"wasm-timer",
]
[[package]]
name = "libp2p-core"
version = "0.20.1"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
dependencies = [
"asn1_der",
"bs58",
"ed25519-dalek",
"either",
"fnv",
"futures 0.3.5",
"futures-timer",
"lazy_static",
"libsecp256k1",
"log 0.4.11",
"multihash",
"multistream-select 0.8.2 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"parity-multiaddr 0.9.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"parking_lot 0.10.2",
"pin-project",
"prost",
"prost-build",
"rand 0.7.3",
"ring",
"rw-stream-sink",
"sha2 0.8.2",
"smallvec 1.4.1",
"thiserror",
"unsigned-varint 0.4.0",
"void",
"zeroize",
]
[[package]]
name = "libp2p-core"
version = "0.20.1"
@ -2753,10 +2666,43 @@ dependencies = [
"zeroize",
]
[[package]]
name = "libp2p-core"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"asn1_der",
"bs58",
"ed25519-dalek",
"either",
"fnv",
"futures 0.3.5",
"futures-timer",
"lazy_static",
"libsecp256k1",
"log 0.4.11",
"multihash",
"multistream-select 0.8.2 (git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef)",
"parity-multiaddr 0.9.1 (git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef)",
"parking_lot 0.10.2",
"pin-project",
"prost",
"prost-build",
"rand 0.7.3",
"ring",
"rw-stream-sink",
"sha2 0.8.2",
"smallvec 1.4.1",
"thiserror",
"unsigned-varint 0.4.0",
"void",
"zeroize",
]
[[package]]
name = "libp2p-core-derive"
version = "0.20.2"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"quote",
"syn",
@ -2764,18 +2710,18 @@ dependencies = [
[[package]]
name = "libp2p-dns"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"futures 0.3.5",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
]
[[package]]
name = "libp2p-gossipsub"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"base64 0.11.0",
"byteorder",
@ -2784,7 +2730,7 @@ dependencies = [
"futures 0.3.5",
"futures_codec",
"hex_fmt",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"libp2p-swarm",
"log 0.4.11",
"lru_time_cache",
@ -2799,11 +2745,11 @@ dependencies = [
[[package]]
name = "libp2p-identify"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"futures 0.3.5",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"libp2p-swarm",
"log 0.4.11",
"prost",
@ -2814,14 +2760,14 @@ dependencies = [
[[package]]
name = "libp2p-mplex"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"bytes 0.5.6",
"fnv",
"futures 0.3.5",
"futures_codec",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
"parking_lot 0.10.2",
"unsigned-varint 0.4.0",
@ -2829,14 +2775,14 @@ dependencies = [
[[package]]
name = "libp2p-noise"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.23.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"bytes 0.5.6",
"curve25519-dalek",
"futures 0.3.5",
"lazy_static",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
"prost",
"prost-build",
@ -2848,42 +2794,13 @@ dependencies = [
"zeroize",
]
[[package]]
name = "libp2p-secio"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
dependencies = [
"aes-ctr 0.3.0",
"ctr 0.3.2",
"futures 0.3.5",
"hmac 0.7.1",
"js-sys",
"lazy_static",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"log 0.4.11",
"parity-send-wrapper",
"pin-project",
"prost",
"prost-build",
"quicksink",
"rand 0.7.3",
"ring",
"rw-stream-sink",
"sha2 0.8.2",
"static_assertions",
"twofish",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "libp2p-swarm"
version = "0.20.1"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"futures 0.3.5",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
"rand 0.7.3",
"smallvec 1.4.1",
@ -2893,14 +2810,14 @@ dependencies = [
[[package]]
name = "libp2p-tcp"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"futures 0.3.5",
"futures-timer",
"get_if_addrs",
"ipnet",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
"socket2",
"tokio 0.2.22",
@ -2908,13 +2825,13 @@ dependencies = [
[[package]]
name = "libp2p-websocket"
version = "0.21.1"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.22.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"async-tls",
"either",
"futures 0.3.5",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"log 0.4.11",
"quicksink",
"rustls",
@ -2927,11 +2844,11 @@ dependencies = [
[[package]]
name = "libp2p-yamux"
version = "0.20.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
version = "0.21.0"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"futures 0.3.5",
"libp2p-core 0.20.1 (git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16)",
"libp2p-core 0.21.0",
"parking_lot 0.10.2",
"thiserror",
"yamux",
@ -2978,7 +2895,7 @@ dependencies = [
[[package]]
name = "lighthouse"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"account_manager",
"account_utils",
@ -3296,7 +3213,7 @@ checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce"
[[package]]
name = "multistream-select"
version = "0.8.2"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"bytes 0.5.6",
"futures 0.3.5",
@ -3584,7 +3501,7 @@ dependencies = [
[[package]]
name = "parity-multiaddr"
version = "0.9.1"
source = "git+https://github.com/sigp/rust-libp2p?rev=f1b660a1a96c1b6198cd62062e75d357893faf16#f1b660a1a96c1b6198cd62062e75d357893faf16"
source = "git+https://github.com/sigp/rust-libp2p?rev=5139ec3ace4ad52506f217d790f0a9425274caef#5139ec3ace4ad52506f217d790f0a9425274caef"
dependencies = [
"arrayref",
"bs58",
@ -3628,12 +3545,6 @@ dependencies = [
"serde",
]
[[package]]
name = "parity-send-wrapper"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
[[package]]
name = "parking_lot"
version = "0.9.0"
@ -5191,15 +5102,6 @@ dependencies = [
"types",
]
[[package]]
name = "stream-cipher"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c"
dependencies = [
"generic-array 0.12.3",
]
[[package]]
name = "stream-cipher"
version = "0.4.1"
@ -5899,17 +5801,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]]
name = "twofish"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1"
dependencies = [
"block-cipher-trait",
"byteorder",
"opaque-debug 0.2.3",
]
[[package]]
name = "typeable"
version = "0.1.2"

View File

@ -39,11 +39,11 @@ environment = { path = "../../lighthouse/environment" }
rand = "0.7.3"
[dependencies.libp2p]
#version = "0.19.1"
#version = "0.23.0"
git = "https://github.com/sigp/rust-libp2p"
rev = "f1b660a1a96c1b6198cd62062e75d357893faf16"
rev = "5139ec3ace4ad52506f217d790f0a9425274caef"
default-features = false
features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns", "secio", "tcp-tokio"]
features = ["websocket", "identify", "mplex", "yamux", "noise", "gossipsub", "dns", "tcp-tokio"]
[dev-dependencies]
tokio = { version = "0.2.21", features = ["full"] }

View File

@ -7,14 +7,10 @@ use crate::EnrExt;
use crate::{NetworkConfig, NetworkGlobals, PeerAction};
use futures::prelude::*;
use libp2p::core::{
identity::Keypair,
multiaddr::Multiaddr,
muxing::StreamMuxerBox,
transport::boxed::Boxed,
upgrade::{InboundUpgradeExt, OutboundUpgradeExt},
identity::Keypair, multiaddr::Multiaddr, muxing::StreamMuxerBox, transport::boxed::Boxed,
};
use libp2p::{
core, noise, secio,
core, noise,
swarm::{SwarmBuilder, SwarmEvent},
PeerId, Swarm, Transport,
};
@ -239,7 +235,7 @@ impl<TSpec: EthSpec> Service<TSpec> {
endpoint: _,
num_established,
} => {
debug!(self.log, "Connection closed"; "peer_id"=> peer_id.to_string(), "cause" => cause.to_string(), "connections" => num_established);
debug!(self.log, "Connection closed"; "peer_id"=> peer_id.to_string(), "cause" => format!("{:?}", cause), "connections" => num_established);
}
SwarmEvent::NewListenAddr(multiaddr) => {
return Libp2pEvent::NewListenAddr(multiaddr)
@ -290,7 +286,6 @@ impl<TSpec: EthSpec> Service<TSpec> {
/// The implementation supports TCP/IP, WebSockets over TCP/IP, noise as the encryption layer, and
/// yamux or mplex as the multiplexing layer.
fn build_transport(
local_private_key: Keypair,
) -> Result<Boxed<(PeerId, StreamMuxerBox), Error>, Error> {
@ -302,47 +297,18 @@ fn build_transport(
transport.or_transport(libp2p::websocket::WsConfig::new(trans_clone))
};
// Authentication
let transport = transport
.and_then(move |stream, endpoint| {
let upgrade = core::upgrade::SelectUpgrade::new(
secio::SecioConfig::new(local_private_key.clone()),
generate_noise_config(&local_private_key),
);
core::upgrade::apply(stream, upgrade, endpoint, core::upgrade::Version::V1).and_then(
|out| async move {
match out {
// Secio was negotiated
core::either::EitherOutput::First((remote_id, out)) => {
Ok((core::either::EitherOutput::First(out), remote_id))
}
// Noise was negotiated
core::either::EitherOutput::Second((remote_id, out)) => {
Ok((core::either::EitherOutput::Second(out), remote_id))
}
}
},
)
})
.timeout(Duration::from_secs(20));
// Multiplexing
let transport = transport
.and_then(move |(stream, peer_id), endpoint| {
let peer_id2 = peer_id.clone();
let upgrade = core::upgrade::SelectUpgrade::new(
libp2p::mplex::MplexConfig::new(),
libp2p::yamux::Config::default(),
)
.map_inbound(move |muxer| (peer_id, muxer))
.map_outbound(move |muxer| (peer_id2, muxer));
core::upgrade::apply(stream, upgrade, endpoint, core::upgrade::Version::V1)
.map_ok(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer)))
})
.timeout(Duration::from_secs(20))
Ok(transport
.upgrade(core::upgrade::Version::V1)
.authenticate(generate_noise_config(&local_private_key))
.multiplex(core::upgrade::SelectUpgrade::new(
libp2p::mplex::MplexConfig::new(),
libp2p::yamux::Config::default(),
))
.map(|(peer, muxer), _| (peer, core::muxing::StreamMuxerBox::new(muxer)))
.timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(10))
.map_err(|err| Error::new(ErrorKind::Other, err))
.boxed();
Ok(transport)
.boxed())
}
// Useful helper functions for debugging. Currently not used in the client.