mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Bump libp2p to 0.40.0 (#10035)
* Bump libp2p to 0.40.0-rc.1 * Fix PingFailure import * Reduce the number of compilation errors (this is a FIXME commit) * Bump libp2p to 0.40.0-rc.2 * Fix sc-network::Behaviour to inject events into fields * Fix some NetworkBehaviourAction types * More fixes * More fixes * More fixes * Fix DiscoveryBehaviour * Fix PeerInfoBehaviour * Fix RequestResponsesBehaviour * Fix RequestResponsesBehaviour * Fix Notifications * Fix NetworkWorker * Fix Behaviour * Please borrowchk * Please borrowchk * Please borrowchk * Fix fmt * Cover all cases in matches * Fix some clippy warnings * Fix into_peer_id -> to_peer_id * Fix some warnings * Fix some inject_dial_failure FIXMEs * Fix DiscoveryBehaviour::inject_dial_failure * Fix RequestResponsesBehaviour::inject_dial_failure * Fix the order of inject_connection_closed PeerInfoBehaviour events * Make KademliaEvent with filtering unreachable * Fix Notifications::inject_dial_failure * Use concurrent_dial_errors in NetworkWorker * Remove commented-out RequestResponsesBehaviour::inject_addr_reach_failure * Fix tests * Dont report new PendingConnectionError and DialError variants to metrics * Bump libp2p to 0.40.0 * Add fn inject_listen_failure and inject_address_change * Review fixes
This commit is contained in:
Generated
+165
-227
@@ -545,6 +545,12 @@ dependencies = [
|
||||
"sp-std",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bimap"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50ae17cabbc8a38a1e3e4c1a6a664e9a09672dc14d0896fa8d865d3a5a446b07"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.2"
|
||||
@@ -1592,6 +1598,12 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clonable"
|
||||
version = "0.9.0"
|
||||
@@ -1874,12 +1886,6 @@ dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.0"
|
||||
@@ -3388,9 +3394,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
||||
|
||||
[[package]]
|
||||
name = "libp2p"
|
||||
version = "0.39.1"
|
||||
version = "0.40.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9004c06878ef8f3b4b4067e69a140d87ed20bf777287f82223e49713b36ee433"
|
||||
checksum = "3bec54343492ba5940a6c555e512c6721139835d28c59bc22febece72dfd0d9d"
|
||||
dependencies = [
|
||||
"atomic",
|
||||
"bytes 1.0.1",
|
||||
@@ -3404,12 +3410,14 @@ dependencies = [
|
||||
"libp2p-identify",
|
||||
"libp2p-kad",
|
||||
"libp2p-mdns",
|
||||
"libp2p-metrics",
|
||||
"libp2p-mplex",
|
||||
"libp2p-noise",
|
||||
"libp2p-ping",
|
||||
"libp2p-plaintext",
|
||||
"libp2p-pnet",
|
||||
"libp2p-relay",
|
||||
"libp2p-rendezvous",
|
||||
"libp2p-request-response",
|
||||
"libp2p-swarm",
|
||||
"libp2p-swarm-derive",
|
||||
@@ -3427,9 +3435,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-core"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af9b4abdeaa420593a297c8592f63fad4234f4b88dc9343b8fd8e736c35faa59"
|
||||
checksum = "bef22d9bba1e8bcb7ec300073e6802943fe8abb8190431842262b5f1c30abba1"
|
||||
dependencies = [
|
||||
"asn1_der",
|
||||
"bs58",
|
||||
@@ -3439,16 +3447,16 @@ dependencies = [
|
||||
"futures 0.3.16",
|
||||
"futures-timer 3.0.2",
|
||||
"lazy_static",
|
||||
"libsecp256k1 0.5.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"multiaddr",
|
||||
"multihash 0.14.0",
|
||||
"multistream-select",
|
||||
"parking_lot 0.11.1",
|
||||
"pin-project 1.0.8",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"rand 0.7.3",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.8.4",
|
||||
"ring",
|
||||
"rw-stream-sink",
|
||||
"sha2 0.9.8",
|
||||
@@ -3461,9 +3469,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-deflate"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66097fccc0b7f8579f90a03ea76ba6196332ea049fd07fd969490a06819dcdc8"
|
||||
checksum = "51a800adb195f33de63f4b17b63fe64cfc23bf2c6a0d3d0d5321328664e65197"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"futures 0.3.16",
|
||||
@@ -3472,9 +3480,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-dns"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58ff08b3196b85a17f202d80589e93b1660a574af67275706657fdc762e42c32"
|
||||
checksum = "bb8f89d15cb6e3c5bc22afff7513b11bab7856f2872d3cfba86f7f63a06bc498"
|
||||
dependencies = [
|
||||
"async-std-resolver",
|
||||
"futures 0.3.16",
|
||||
@@ -3486,9 +3494,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-floodsub"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "404eca8720967179dac7a5b4275eb91f904a53859c69ca8d018560ad6beb214f"
|
||||
checksum = "aab3d7210901ea51b7bae2b581aa34521797af8c4ec738c980bda4a06434067f"
|
||||
dependencies = [
|
||||
"cuckoofilter",
|
||||
"fnv",
|
||||
@@ -3496,17 +3504,17 @@ dependencies = [
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.7.3",
|
||||
"smallvec 1.7.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-gossipsub"
|
||||
version = "0.32.0"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1cc48709bcbc3a3321f08a73560b4bbb4166a7d56f6fdb615bc775f4f91058e"
|
||||
checksum = "dfeead619eb5dac46e65acc78c535a60aaec803d1428cca6407c3a4fc74d698d"
|
||||
dependencies = [
|
||||
"asynchronous-codec 0.6.0",
|
||||
"base64 0.13.0",
|
||||
@@ -3518,8 +3526,8 @@ dependencies = [
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.7.3",
|
||||
"regex",
|
||||
"sha2 0.9.8",
|
||||
@@ -3530,25 +3538,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-identify"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7b61f6cf07664fb97016c318c4d4512b3dd4cc07238607f3f0163245f99008e"
|
||||
checksum = "cca1275574183f288ff8b72d535d5ffa5ea9292ef7829af8b47dcb197c7b0dcd"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"lru 0.6.6",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"smallvec 1.7.0",
|
||||
"wasm-timer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-kad"
|
||||
version = "0.31.0"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50ed78489c87924235665a0ab345b298ee34dff0f7ad62c0ba6608b2144fb75e"
|
||||
checksum = "a2297dc0ca285f3a09d1368bde02449e539b46f94d32d53233f53f6625bcd3ba"
|
||||
dependencies = [
|
||||
"arrayvec 0.5.2",
|
||||
"asynchronous-codec 0.6.0",
|
||||
@@ -3559,8 +3568,8 @@ dependencies = [
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.7.3",
|
||||
"sha2 0.9.8",
|
||||
"smallvec 1.7.0",
|
||||
@@ -3572,9 +3581,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mdns"
|
||||
version = "0.31.0"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a29e6cbc2a24b8471b6567e580a0e8e7b70a6d0f0ea2be0844d1e842d7d4fa33"
|
||||
checksum = "14c864b64bdc8a84ff3910a0df88e6535f256191a450870f1e7e10cbf8e64d45"
|
||||
dependencies = [
|
||||
"async-io",
|
||||
"data-encoding",
|
||||
@@ -3592,10 +3601,24 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mplex"
|
||||
version = "0.29.0"
|
||||
name = "libp2p-metrics"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "313d9ea526c68df4425f580024e67a9d3ffd49f2c33de5154b1f5019816f7a99"
|
||||
checksum = "4af432fcdd2f8ba4579b846489f8f0812cfd738ced2c0af39df9b1c48bbb6ab2"
|
||||
dependencies = [
|
||||
"libp2p-core",
|
||||
"libp2p-identify",
|
||||
"libp2p-kad",
|
||||
"libp2p-ping",
|
||||
"libp2p-swarm",
|
||||
"open-metrics-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mplex"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f2cd64ef597f40e14bfce0497f50ecb63dd6d201c61796daeb4227078834fbf"
|
||||
dependencies = [
|
||||
"asynchronous-codec 0.6.0",
|
||||
"bytes 1.0.1",
|
||||
@@ -3611,9 +3634,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-noise"
|
||||
version = "0.32.0"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f1db7212f342b6ba7c981cc40e31f76e9e56cb48e65fa4c142ecaca5839523e"
|
||||
checksum = "a8772c7a99088221bb7ca9c5c0574bf55046a7ab4c319f3619b275f28c8fb87a"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"curve25519-dalek 3.0.2",
|
||||
@@ -3621,8 +3644,8 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"libp2p-core",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.8.4",
|
||||
"sha2 0.9.8",
|
||||
"snow",
|
||||
@@ -3633,9 +3656,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-ping"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2482cfd9eb0b7a0baaf3e7b329dc4f2785181a161b1a47b7192f8d758f54a439"
|
||||
checksum = "80ef7b0ec5cf06530d9eb6cf59ae49d46a2c45663bde31c25a12f682664adbcf"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"libp2p-core",
|
||||
@@ -3648,26 +3671,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-plaintext"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13b4783e5423870b9a5c199f65a7a3bc66d86ab56b2b9beebf3c338d889cf8e4"
|
||||
checksum = "5fba1a6ff33e4a274c89a3b1d78b9f34f32af13265cc5c46c16938262d4e945a"
|
||||
dependencies = [
|
||||
"asynchronous-codec 0.6.0",
|
||||
"bytes 1.0.1",
|
||||
"futures 0.3.16",
|
||||
"libp2p-core",
|
||||
"log 0.4.14",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"unsigned-varint 0.7.0",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-pnet"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07cb4dd4b917e5b40ddefe49b96b07adcd8d342e0317011d175b7b2bb1dcc974"
|
||||
checksum = "0f1a458bbda880107b5b36fcb9b5a1ef0c329685da0e203ed692a8ebe64cc92c"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"log 0.4.14",
|
||||
@@ -3679,9 +3702,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-relay"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0133f6cfd81cdc16e716de2982e012c62e6b9d4f12e41967b3ee361051c622aa"
|
||||
checksum = "2852b61c90fa8ce3c8fcc2aba76e6cefc20d648f9df29157d6b3a916278ef3e3"
|
||||
dependencies = [
|
||||
"asynchronous-codec 0.6.0",
|
||||
"bytes 1.0.1",
|
||||
@@ -3691,8 +3714,8 @@ dependencies = [
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"pin-project 1.0.8",
|
||||
"prost 0.8.0",
|
||||
"prost-build 0.8.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.7.3",
|
||||
"smallvec 1.7.0",
|
||||
"unsigned-varint 0.7.0",
|
||||
@@ -3701,10 +3724,32 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-request-response"
|
||||
version = "0.12.0"
|
||||
name = "libp2p-rendezvous"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06cdae44b6821466123af93cbcdec7c9e6ba9534a8af9cdc296446d39416d241"
|
||||
checksum = "14a6d2b9e7677eff61dc3d2854876aaf3976d84a01ef6664b610c77a0c9407c5"
|
||||
dependencies = [
|
||||
"asynchronous-codec 0.6.0",
|
||||
"bimap",
|
||||
"futures 0.3.16",
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"rand 0.8.4",
|
||||
"sha2 0.9.8",
|
||||
"thiserror",
|
||||
"unsigned-varint 0.7.0",
|
||||
"void",
|
||||
"wasm-timer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-request-response"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a877a4ced6d46bf84677e1974e8cf61fb434af73b2e96fb48d6cb6223a4634d8"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 1.0.1",
|
||||
@@ -3712,8 +3757,7 @@ dependencies = [
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log 0.4.14",
|
||||
"lru 0.6.6",
|
||||
"minicbor",
|
||||
"lru 0.7.0",
|
||||
"rand 0.7.3",
|
||||
"smallvec 1.7.0",
|
||||
"unsigned-varint 0.7.0",
|
||||
@@ -3722,9 +3766,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-swarm"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7083861341e1555467863b4cd802bea1e8c4787c0f7b5110097d0f1f3248f9a9"
|
||||
checksum = "3f5184a508f223bc100a12665517773fb8730e9f36fc09eefb670bf01b107ae9"
|
||||
dependencies = [
|
||||
"either",
|
||||
"futures 0.3.16",
|
||||
@@ -3738,9 +3782,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-swarm-derive"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab8cb308d4fc854869f5abb54fdab0833d2cf670d407c745849dc47e6e08d79c"
|
||||
checksum = "072c290f727d39bdc4e9d6d1c847978693d25a673bd757813681e33e5f6c00c2"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
@@ -3748,9 +3792,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-tcp"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79edd26b6b4bb5feee210dcda562dca186940dfecb0024b979c3f50824b3bf28"
|
||||
checksum = "7399c5b6361ef525d41c11fcf51635724f832baf5819b30d3d873eabb4fbae4b"
|
||||
dependencies = [
|
||||
"async-io",
|
||||
"futures 0.3.16",
|
||||
@@ -3765,9 +3809,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-uds"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "280e793440dd4e9f273d714f4497325c72cddb0fe85a49f9a03c88f41dd20182"
|
||||
checksum = "b8b7563e46218165dfd60f64b96f7ce84590d75f53ecbdc74a7dd01450dc5973"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"futures 0.3.16",
|
||||
@@ -3777,9 +3821,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-wasm-ext"
|
||||
version = "0.29.0"
|
||||
version = "0.30.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f553b7140fad3d7a76f50497b0ea591e26737d9607428a75509fc191e4d1b1f6"
|
||||
checksum = "1008a302b73c5020251f9708c653f5ed08368e530e247cc9cd2f109ff30042cf"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"js-sys",
|
||||
@@ -3791,9 +3835,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-websocket"
|
||||
version = "0.30.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddf99dcbf5063e9d59087f61b1e85c686ceab2f5abedb472d32288065c0e5e27"
|
||||
checksum = "22e12df82d1ed64969371a9e65ea92b91064658604cc2576c2757f18ead9a1cf"
|
||||
dependencies = [
|
||||
"either",
|
||||
"futures 0.3.16",
|
||||
@@ -3802,16 +3846,16 @@ dependencies = [
|
||||
"log 0.4.14",
|
||||
"quicksink",
|
||||
"rw-stream-sink",
|
||||
"soketto 0.4.2",
|
||||
"soketto 0.7.0",
|
||||
"url 2.2.1",
|
||||
"webpki-roots",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-yamux"
|
||||
version = "0.33.0"
|
||||
version = "0.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "214cc0dd9c37cbed27f0bb1eba0c41bbafdb93a8be5e9d6ae1e6b4b42cd044bf"
|
||||
checksum = "4e7362abb8867d7187e7e93df17f460d554c997fc5c8ac57dc1259057f6889af"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"libp2p-core",
|
||||
@@ -3832,25 +3876,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"base64 0.12.3",
|
||||
"digest 0.9.0",
|
||||
"hmac-drbg",
|
||||
"libsecp256k1-core 0.2.2",
|
||||
"libsecp256k1-gen-ecmult 0.2.1",
|
||||
"libsecp256k1-gen-genmult 0.2.1",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"sha2 0.9.8",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1"
|
||||
version = "0.7.0"
|
||||
@@ -3861,26 +3886,15 @@ dependencies = [
|
||||
"base64 0.13.0",
|
||||
"digest 0.9.0",
|
||||
"hmac-drbg",
|
||||
"libsecp256k1-core 0.3.0",
|
||||
"libsecp256k1-gen-ecmult 0.3.0",
|
||||
"libsecp256k1-gen-genmult 0.3.0",
|
||||
"libsecp256k1-core",
|
||||
"libsecp256k1-gen-ecmult",
|
||||
"libsecp256k1-gen-genmult",
|
||||
"rand 0.8.4",
|
||||
"serde",
|
||||
"sha2 0.9.8",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-core"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80"
|
||||
dependencies = [
|
||||
"crunchy",
|
||||
"digest 0.9.0",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-core"
|
||||
version = "0.3.0"
|
||||
@@ -3892,31 +3906,13 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-gen-ecmult"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3"
|
||||
dependencies = [
|
||||
"libsecp256k1-core 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-gen-ecmult"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809"
|
||||
dependencies = [
|
||||
"libsecp256k1-core 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1-gen-genmult"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d"
|
||||
dependencies = [
|
||||
"libsecp256k1-core 0.2.2",
|
||||
"libsecp256k1-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3925,7 +3921,7 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c"
|
||||
dependencies = [
|
||||
"libsecp256k1-core 0.3.0",
|
||||
"libsecp256k1-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4205,26 +4201,6 @@ dependencies = [
|
||||
"log 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minicbor"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea79ce4ab9f445ec6b71833a2290ac0a29c9dde0fa7cae4c481eecae021d9bd9"
|
||||
dependencies = [
|
||||
"minicbor-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minicbor-derive"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19ce18b5423c573a13e80cb3046ea0af6379ef725dc3af4886bdb8f4e5093068"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
@@ -5067,6 +5043,29 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "open-metrics-client"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7337d80c23c2d8b1349563981bc4fb531220733743ba8115454a67b181173f0d"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"itoa",
|
||||
"open-metrics-client-derive-text-encode",
|
||||
"owning_ref",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "open-metrics-client-derive-text-encode"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a15c83b586f00268c619c1cb3340ec1a6f59dd9ba1d9833a273a68e6d5cd8ffc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.35"
|
||||
@@ -5345,7 +5344,7 @@ dependencies = [
|
||||
"frame-system",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"libsecp256k1 0.7.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"pallet-beefy",
|
||||
"pallet-mmr",
|
||||
@@ -5405,7 +5404,7 @@ dependencies = [
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"hex-literal",
|
||||
"libsecp256k1 0.7.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"pallet-balances",
|
||||
"pallet-contracts-primitives",
|
||||
@@ -6557,23 +6556,13 @@ dependencies = [
|
||||
"sha-1 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
|
||||
dependencies = [
|
||||
"fixedbitset 0.2.0",
|
||||
"indexmap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f"
|
||||
dependencies = [
|
||||
"fixedbitset 0.4.0",
|
||||
"fixedbitset",
|
||||
"indexmap",
|
||||
]
|
||||
|
||||
@@ -6847,16 +6836,6 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"prost-derive 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.9.0"
|
||||
@@ -6864,25 +6843,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"prost-derive 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-build"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"heck",
|
||||
"itertools",
|
||||
"log 0.4.14",
|
||||
"multimap",
|
||||
"petgraph 0.5.1",
|
||||
"prost 0.8.0",
|
||||
"prost-types 0.8.0",
|
||||
"tempfile",
|
||||
"which",
|
||||
"prost-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6897,27 +6858,14 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"log 0.4.14",
|
||||
"multimap",
|
||||
"petgraph 0.6.0",
|
||||
"prost 0.9.0",
|
||||
"prost-types 0.9.0",
|
||||
"petgraph",
|
||||
"prost",
|
||||
"prost-types",
|
||||
"regex",
|
||||
"tempfile",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.9.0"
|
||||
@@ -6931,16 +6879,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"prost 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.9.0"
|
||||
@@ -6948,7 +6886,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"prost 0.9.0",
|
||||
"prost",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7594,9 +7532,9 @@ checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
|
||||
|
||||
[[package]]
|
||||
name = "salsa20"
|
||||
version = "0.8.1"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecbd2eb639fd7cab5804a0837fe373cc2172d15437e804c054a9fb885cb923b0"
|
||||
checksum = "0c0fbb5f676da676c260ba276a8f43a8dc67cf02d1438423aeb1c677a7212686"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
@@ -7632,8 +7570,8 @@ dependencies = [
|
||||
"libp2p",
|
||||
"log 0.4.14",
|
||||
"parity-scale-codec",
|
||||
"prost 0.9.0",
|
||||
"prost-build 0.9.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"quickcheck",
|
||||
"rand 0.7.3",
|
||||
"sc-client-api",
|
||||
@@ -8068,7 +8006,7 @@ version = "0.10.0-dev"
|
||||
dependencies = [
|
||||
"hex-literal",
|
||||
"lazy_static",
|
||||
"libsecp256k1 0.7.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.11.1",
|
||||
@@ -8282,8 +8220,8 @@ dependencies = [
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.11.1",
|
||||
"pin-project 1.0.8",
|
||||
"prost 0.9.0",
|
||||
"prost-build 0.9.0",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"quickcheck",
|
||||
"rand 0.7.3",
|
||||
"sc-block-builder",
|
||||
@@ -9159,7 +9097,6 @@ checksum = "b5c71ed3d54db0a699f4948e1bb3e45b450fa31fe602621dee6680361d569c88"
|
||||
dependencies = [
|
||||
"base64 0.12.3",
|
||||
"bytes 0.5.6",
|
||||
"flate2",
|
||||
"futures 0.3.16",
|
||||
"httparse",
|
||||
"log 0.4.14",
|
||||
@@ -9175,6 +9112,7 @@ checksum = "083624472e8817d44d02c0e55df043737ff11f279af924abdf93845717c2b75c"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bytes 1.0.1",
|
||||
"flate2",
|
||||
"futures 0.3.16",
|
||||
"httparse",
|
||||
"log 0.4.14",
|
||||
@@ -9442,7 +9380,7 @@ dependencies = [
|
||||
"hex-literal",
|
||||
"impl-serde",
|
||||
"lazy_static",
|
||||
"libsecp256k1 0.7.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"merlin",
|
||||
"num-traits",
|
||||
@@ -9562,7 +9500,7 @@ version = "4.0.0-dev"
|
||||
dependencies = [
|
||||
"futures 0.3.16",
|
||||
"hash-db",
|
||||
"libsecp256k1 0.7.0",
|
||||
"libsecp256k1",
|
||||
"log 0.4.14",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.11.1",
|
||||
|
||||
@@ -23,7 +23,7 @@ derive_more = "0.99.16"
|
||||
futures = "0.3.9"
|
||||
futures-timer = "3.0.1"
|
||||
ip_network = "0.4.0"
|
||||
libp2p = { version = "0.39.1", default-features = false, features = ["kad"] }
|
||||
libp2p = { version = "0.40.0", default-features = false, features = ["kad"] }
|
||||
log = "0.4.8"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.10.0-dev" }
|
||||
prost = "0.9"
|
||||
|
||||
@@ -18,7 +18,7 @@ regex = "1.5.4"
|
||||
tokio = { version = "1.13", features = [ "signal", "rt-multi-thread" ] }
|
||||
futures = "0.3.9"
|
||||
fdlimit = "0.2.1"
|
||||
libp2p = "0.39.1"
|
||||
libp2p = "0.40.0"
|
||||
parity-scale-codec = "2.3.1"
|
||||
hex = "0.4.2"
|
||||
rand = "0.7.3"
|
||||
|
||||
@@ -65,7 +65,7 @@ impl BuildSpecCmd {
|
||||
|
||||
if spec.boot_nodes().is_empty() && !self.disable_default_bootnode {
|
||||
let keys = network_config.node_key.into_keypair()?;
|
||||
let peer_id = keys.public().into_peer_id();
|
||||
let peer_id = keys.public().to_peer_id();
|
||||
let addr = MultiaddrWithPeerId {
|
||||
multiaddr: build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(30333u16)],
|
||||
peer_id,
|
||||
|
||||
@@ -42,7 +42,7 @@ impl GenerateNodeKeyCmd {
|
||||
pub fn run(&self) -> Result<(), Error> {
|
||||
let keypair = libp2p_ed25519::Keypair::generate();
|
||||
let secret = keypair.secret();
|
||||
let peer_id = PublicKey::Ed25519(keypair.public()).into_peer_id();
|
||||
let peer_id = PublicKey::Ed25519(keypair.public()).to_peer_id();
|
||||
let secret_hex = hex::encode(secret.as_ref());
|
||||
|
||||
match &self.file {
|
||||
|
||||
@@ -47,7 +47,7 @@ impl InspectNodeKeyCmd {
|
||||
ed25519::SecretKey::from_bytes(&mut file_content).map_err(|_| "Bad node key file")?;
|
||||
|
||||
let keypair = ed25519::Keypair::from(secret);
|
||||
let peer_id = PublicKey::Ed25519(keypair.public()).into_peer_id();
|
||||
let peer_id = PublicKey::Ed25519(keypair.public()).to_peer_id();
|
||||
|
||||
println!("{}", peer_id);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
thiserror = "1.0.30"
|
||||
libp2p = { version = "0.39.1", default-features = false }
|
||||
libp2p = { version = "0.40.0", default-features = false }
|
||||
log = "0.4.8"
|
||||
futures = { version = "0.3.1", features = ["thread-pool"] }
|
||||
futures-timer = "3.0.1"
|
||||
|
||||
@@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
futures = "0.3.9"
|
||||
futures-timer = "3.0.1"
|
||||
libp2p = { version = "0.39.1", default-features = false }
|
||||
libp2p = { version = "0.40.0", default-features = false }
|
||||
log = "0.4.8"
|
||||
lru = "0.7.0"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
|
||||
|
||||
@@ -64,11 +64,11 @@ unsigned-varint = { version = "0.6.0", features = [
|
||||
] }
|
||||
void = "1.0.2"
|
||||
zeroize = "1.4.2"
|
||||
libp2p = "0.39.1"
|
||||
libp2p = "0.40.0"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3"
|
||||
libp2p = { version = "0.39.1", default-features = false }
|
||||
libp2p = { version = "0.40.0", default-features = false }
|
||||
quickcheck = "1.0.3"
|
||||
rand = "0.7.2"
|
||||
sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" }
|
||||
|
||||
@@ -32,7 +32,10 @@ use libp2p::{
|
||||
core::{Multiaddr, PeerId, PublicKey},
|
||||
identify::IdentifyInfo,
|
||||
kad::record,
|
||||
swarm::{toggle::Toggle, NetworkBehaviourAction, NetworkBehaviourEventProcess, PollParameters},
|
||||
swarm::{
|
||||
toggle::Toggle, NetworkBehaviour, NetworkBehaviourAction, NetworkBehaviourEventProcess,
|
||||
PollParameters,
|
||||
},
|
||||
NetworkBehaviour,
|
||||
};
|
||||
use log::debug;
|
||||
@@ -58,7 +61,7 @@ pub use crate::request_responses::{
|
||||
|
||||
/// General behaviour of the network. Combines all protocols together.
|
||||
#[derive(NetworkBehaviour)]
|
||||
#[behaviour(out_event = "BehaviourOut<B>", poll_method = "poll")]
|
||||
#[behaviour(out_event = "BehaviourOut<B>", poll_method = "poll", event_process = true)]
|
||||
pub struct Behaviour<B: BlockT> {
|
||||
/// All the substrate-specific protocols.
|
||||
substrate: Protocol<B>,
|
||||
@@ -512,11 +515,12 @@ impl<B: BlockT> NetworkBehaviourEventProcess<DiscoveryOut> for Behaviour<B> {
|
||||
}
|
||||
|
||||
impl<B: BlockT> Behaviour<B> {
|
||||
fn poll<TEv>(
|
||||
fn poll(
|
||||
&mut self,
|
||||
_cx: &mut Context,
|
||||
_: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<TEv, BehaviourOut<B>>> {
|
||||
) -> Poll<NetworkBehaviourAction<BehaviourOut<B>, <Self as NetworkBehaviour>::ProtocolsHandler>>
|
||||
{
|
||||
if let Some(event) = self.events.pop_front() {
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event))
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ use libp2p::{
|
||||
UpgradeInfo,
|
||||
},
|
||||
swarm::{
|
||||
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
|
||||
OneShotHandler, PollParameters, ProtocolsHandler,
|
||||
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, OneShotHandler, PollParameters,
|
||||
},
|
||||
};
|
||||
use log::{debug, error, trace};
|
||||
@@ -297,12 +296,11 @@ impl<B: BlockT> NetworkBehaviour for Bitswap<B> {
|
||||
self.ready_blocks.push_back((peer, response));
|
||||
}
|
||||
|
||||
fn poll(&mut self, _ctx: &mut Context, _: &mut impl PollParameters) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
>,
|
||||
>{
|
||||
fn poll(
|
||||
&mut self,
|
||||
_ctx: &mut Context,
|
||||
_: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
if let Some((peer_id, message)) = self.ready_blocks.pop_front() {
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
|
||||
@@ -67,8 +67,8 @@ use libp2p::{
|
||||
mdns::{Mdns, MdnsConfig, MdnsEvent},
|
||||
multiaddr::Protocol,
|
||||
swarm::{
|
||||
protocols_handler::multi::IntoMultiHandler, IntoProtocolsHandler, NetworkBehaviour,
|
||||
NetworkBehaviourAction, PollParameters, ProtocolsHandler,
|
||||
protocols_handler::multi::IntoMultiHandler, DialError, IntoProtocolsHandler,
|
||||
NetworkBehaviour, NetworkBehaviourAction, PollParameters, ProtocolsHandler,
|
||||
},
|
||||
};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
@@ -107,7 +107,7 @@ impl DiscoveryConfig {
|
||||
/// Create a default configuration with the given public key.
|
||||
pub fn new(local_public_key: PublicKey) -> Self {
|
||||
Self {
|
||||
local_peer_id: local_public_key.into_peer_id(),
|
||||
local_peer_id: local_public_key.to_peer_id(),
|
||||
permanent_addresses: Vec::new(),
|
||||
dht_random_walk: true,
|
||||
allow_private_ipv4: true,
|
||||
@@ -428,6 +428,29 @@ impl DiscoveryBehaviour {
|
||||
};
|
||||
ip.is_global()
|
||||
}
|
||||
|
||||
fn new_handler_with_replacement(
|
||||
&mut self,
|
||||
pid: ProtocolId,
|
||||
handler: KademliaHandlerProto<QueryId>,
|
||||
) -> <DiscoveryBehaviour as NetworkBehaviour>::ProtocolsHandler {
|
||||
let mut handlers: HashMap<_, _> = self
|
||||
.kademlias
|
||||
.iter_mut()
|
||||
.map(|(p, k)| (p.clone(), NetworkBehaviour::new_handler(k)))
|
||||
.collect();
|
||||
|
||||
if let Some(h) = handlers.get_mut(&pid) {
|
||||
*h = handler
|
||||
}
|
||||
|
||||
IntoMultiHandler::try_from_iter(handlers).expect(
|
||||
"There can be at most one handler per `ProtocolId` and protocol names contain the \
|
||||
`ProtocolId` so no two protocol names in `self.kademlias` can be equal which is the \
|
||||
only error `try_from_iter` can return, therefore this call is guaranteed to succeed; \
|
||||
qed",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Event generated by the `DiscoveryBehaviour`.
|
||||
@@ -527,15 +550,34 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
list
|
||||
}
|
||||
|
||||
fn inject_address_change(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
connection_id: &ConnectionId,
|
||||
old: &ConnectedPoint,
|
||||
new: &ConnectedPoint,
|
||||
) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_address_change(k, peer_id, connection_id, old, new);
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_connection_established(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
self.num_connections += 1;
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_connection_established(k, peer_id, conn, endpoint)
|
||||
NetworkBehaviour::inject_connection_established(
|
||||
k,
|
||||
peer_id,
|
||||
conn,
|
||||
endpoint,
|
||||
failed_addresses,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,14 +589,13 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
|
||||
fn inject_connection_closed(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
_peer_id: &PeerId,
|
||||
_conn: &ConnectionId,
|
||||
_endpoint: &ConnectedPoint,
|
||||
_handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
self.num_connections -= 1;
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_connection_closed(k, peer_id, conn, endpoint)
|
||||
}
|
||||
// NetworkBehaviour::inject_connection_closed on Kademlia<MemoryStore> does nothing.
|
||||
}
|
||||
|
||||
fn inject_disconnected(&mut self, peer_id: &PeerId) {
|
||||
@@ -563,20 +604,25 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
_: Self::ProtocolsHandler,
|
||||
error: &DialError,
|
||||
) {
|
||||
if let Some(peer_id) = peer_id {
|
||||
if let Some(list) = self.ephemeral_addresses.get_mut(peer_id) {
|
||||
list.retain(|a| a != addr);
|
||||
if let DialError::Transport(errors) = error {
|
||||
if let Some(list) = self.ephemeral_addresses.get_mut(&peer_id) {
|
||||
for (addr, _error) in errors {
|
||||
list.retain(|a| a != addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_addr_reach_failure(k, peer_id, addr, error)
|
||||
let handler = k.new_handler();
|
||||
NetworkBehaviour::inject_dial_failure(k, peer_id, handler, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,12 +677,6 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_dial_failure(k, peer_id)
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_new_listener(&mut self, id: ListenerId) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_new_listener(k, id)
|
||||
@@ -649,6 +689,10 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_listen_failure(&mut self, _: &Multiaddr, _: &Multiaddr, _: Self::ProtocolsHandler) {
|
||||
// NetworkBehaviour::inject_listen_failure on Kademlia<MemoryStore> does nothing.
|
||||
}
|
||||
|
||||
fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn std::error::Error + 'static)) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
NetworkBehaviour::inject_listener_error(k, id, err)
|
||||
@@ -665,12 +709,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
>,
|
||||
>{
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
// Immediately process the content of `discovered`.
|
||||
if let Some(ev) = self.pending_events.pop_front() {
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
|
||||
@@ -731,6 +770,10 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
let ev = DiscoveryOut::Discovered(peer);
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
|
||||
},
|
||||
KademliaEvent::InboundPutRecordRequest { .. } |
|
||||
KademliaEvent::InboundAddProviderRequest { .. } => {
|
||||
debug_assert!(false, "We don't use kad filtering at the moment");
|
||||
},
|
||||
KademliaEvent::PendingRoutablePeer { .. } |
|
||||
KademliaEvent::InboundRequestServed { .. } => {
|
||||
// We are not interested in this event at the moment.
|
||||
@@ -847,10 +890,20 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e)
|
||||
},
|
||||
},
|
||||
NetworkBehaviourAction::DialAddress { address } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
|
||||
NetworkBehaviourAction::DialPeer { peer_id, condition } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
|
||||
NetworkBehaviourAction::DialAddress { address, handler } => {
|
||||
let pid = pid.clone();
|
||||
let handler = self.new_handler_with_replacement(pid, handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler })
|
||||
},
|
||||
NetworkBehaviourAction::DialPeer { peer_id, condition, handler } => {
|
||||
let pid = pid.clone();
|
||||
let handler = self.new_handler_with_replacement(pid, handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer {
|
||||
peer_id,
|
||||
condition,
|
||||
handler,
|
||||
})
|
||||
},
|
||||
NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
@@ -888,10 +941,12 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
},
|
||||
MdnsEvent::Expired(_) => {},
|
||||
},
|
||||
NetworkBehaviourAction::DialAddress { address } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
|
||||
NetworkBehaviourAction::DialPeer { peer_id, condition } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
|
||||
NetworkBehaviourAction::DialAddress { .. } => {
|
||||
unreachable!("mDNS never dials!");
|
||||
},
|
||||
NetworkBehaviourAction::DialPeer { .. } => {
|
||||
unreachable!("mDNS never dials!");
|
||||
},
|
||||
NetworkBehaviourAction::NotifyHandler { event, .. } => match event {}, /* `event` is an enum with no variant */
|
||||
NetworkBehaviourAction::ReportObservedAddr { address, score } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::ReportObservedAddr {
|
||||
@@ -940,7 +995,7 @@ impl MdnsWrapper {
|
||||
&mut self,
|
||||
cx: &mut Context<'_>,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<void::Void, MdnsEvent>> {
|
||||
) -> Poll<NetworkBehaviourAction<MdnsEvent, <Mdns as NetworkBehaviour>::ProtocolsHandler>> {
|
||||
loop {
|
||||
match self {
|
||||
Self::Instantiating(fut) =>
|
||||
@@ -1007,13 +1062,13 @@ mod tests {
|
||||
config.finish()
|
||||
};
|
||||
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypair.public().into_peer_id());
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypair.public().to_peer_id());
|
||||
let listen_addr: Multiaddr =
|
||||
format!("/memory/{}", rand::random::<u64>()).parse().unwrap();
|
||||
|
||||
if i == 0 {
|
||||
first_swarm_peer_id_and_addr =
|
||||
Some((keypair.public().into_peer_id(), listen_addr.clone()))
|
||||
Some((keypair.public().to_peer_id(), listen_addr.clone()))
|
||||
}
|
||||
|
||||
swarm.listen_on(listen_addr.clone()).unwrap();
|
||||
|
||||
@@ -186,6 +186,17 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
list
|
||||
}
|
||||
|
||||
fn inject_address_change(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
old: &ConnectedPoint,
|
||||
new: &ConnectedPoint,
|
||||
) {
|
||||
self.ping.inject_address_change(peer_id, conn, old, new);
|
||||
self.identify.inject_address_change(peer_id, conn, old, new);
|
||||
}
|
||||
|
||||
fn inject_connected(&mut self, peer_id: &PeerId) {
|
||||
self.ping.inject_connected(peer_id);
|
||||
self.identify.inject_connected(peer_id);
|
||||
@@ -196,9 +207,12 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
self.ping.inject_connection_established(peer_id, conn, endpoint);
|
||||
self.identify.inject_connection_established(peer_id, conn, endpoint);
|
||||
self.ping
|
||||
.inject_connection_established(peer_id, conn, endpoint, failed_addresses);
|
||||
self.identify
|
||||
.inject_connection_established(peer_id, conn, endpoint, failed_addresses);
|
||||
match self.nodes_info.entry(*peer_id) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(NodeInfo::new(endpoint.clone()));
|
||||
@@ -220,9 +234,12 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
self.ping.inject_connection_closed(peer_id, conn, endpoint);
|
||||
self.identify.inject_connection_closed(peer_id, conn, endpoint);
|
||||
let (ping_handler, identity_handler) = handler.into_inner();
|
||||
self.identify
|
||||
.inject_connection_closed(peer_id, conn, endpoint, identity_handler);
|
||||
self.ping.inject_connection_closed(peer_id, conn, endpoint, ping_handler);
|
||||
|
||||
if let Some(entry) = self.nodes_info.get_mut(peer_id) {
|
||||
entry.endpoints.retain(|ep| ep != endpoint)
|
||||
@@ -256,19 +273,15 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
handler: Self::ProtocolsHandler,
|
||||
error: &libp2p::swarm::DialError,
|
||||
) {
|
||||
self.ping.inject_addr_reach_failure(peer_id, addr, error);
|
||||
self.identify.inject_addr_reach_failure(peer_id, addr, error);
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
self.ping.inject_dial_failure(peer_id);
|
||||
self.identify.inject_dial_failure(peer_id);
|
||||
let (ping_handler, identity_handler) = handler.into_inner();
|
||||
self.identify.inject_dial_failure(peer_id, identity_handler, error);
|
||||
self.ping.inject_dial_failure(peer_id, ping_handler, error);
|
||||
}
|
||||
|
||||
fn inject_new_listener(&mut self, id: ListenerId) {
|
||||
@@ -296,6 +309,18 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
self.identify.inject_expired_external_addr(addr);
|
||||
}
|
||||
|
||||
fn inject_listen_failure(
|
||||
&mut self,
|
||||
local_addr: &Multiaddr,
|
||||
send_back_addr: &Multiaddr,
|
||||
handler: Self::ProtocolsHandler,
|
||||
) {
|
||||
let (ping_handler, identity_handler) = handler.into_inner();
|
||||
self.identify
|
||||
.inject_listen_failure(local_addr, send_back_addr, identity_handler);
|
||||
self.ping.inject_listen_failure(local_addr, send_back_addr, ping_handler);
|
||||
}
|
||||
|
||||
fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn error::Error + 'static)) {
|
||||
self.ping.inject_listener_error(id, err);
|
||||
self.identify.inject_listener_error(id, err);
|
||||
@@ -309,13 +334,8 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent
|
||||
>
|
||||
>{
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
loop {
|
||||
match self.ping.poll(cx, params) {
|
||||
Poll::Pending => break,
|
||||
@@ -324,10 +344,20 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
self.handle_ping_report(&peer, rtt)
|
||||
}
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) => {
|
||||
let handler =
|
||||
IntoProtocolsHandler::select(handler, self.identify.new_handler());
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler })
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) => {
|
||||
let handler =
|
||||
IntoProtocolsHandler::select(handler, self.identify.new_handler());
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer {
|
||||
peer_id,
|
||||
condition,
|
||||
handler,
|
||||
})
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
@@ -362,10 +392,18 @@ impl NetworkBehaviour for PeerInfoBehaviour {
|
||||
IdentifyEvent::Pushed { .. } => {},
|
||||
IdentifyEvent::Sent { .. } => {},
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) => {
|
||||
let handler = IntoProtocolsHandler::select(self.ping.new_handler(), handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler })
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) => {
|
||||
let handler = IntoProtocolsHandler::select(self.ping.new_handler(), handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer {
|
||||
peer_id,
|
||||
condition,
|
||||
handler,
|
||||
})
|
||||
},
|
||||
Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
|
||||
@@ -1362,8 +1362,10 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
self.behaviour.inject_connection_established(peer_id, conn, endpoint)
|
||||
self.behaviour
|
||||
.inject_connection_established(peer_id, conn, endpoint, failed_addresses)
|
||||
}
|
||||
|
||||
fn inject_connection_closed(
|
||||
@@ -1371,8 +1373,9 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
self.behaviour.inject_connection_closed(peer_id, conn, endpoint)
|
||||
self.behaviour.inject_connection_closed(peer_id, conn, endpoint, handler)
|
||||
}
|
||||
|
||||
fn inject_connected(&mut self, peer_id: &PeerId) {
|
||||
@@ -1396,12 +1399,7 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
|
||||
&mut self,
|
||||
cx: &mut std::task::Context,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent
|
||||
>
|
||||
>{
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
if let Some(message) = self.pending_messages.pop_front() {
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(message))
|
||||
}
|
||||
@@ -1562,10 +1560,10 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
|
||||
let event = match self.behaviour.poll(cx, params) {
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => ev,
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }),
|
||||
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }),
|
||||
Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) =>
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
@@ -1778,17 +1776,13 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
|
||||
Poll::Pending
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
handler: Self::ProtocolsHandler,
|
||||
error: &libp2p::swarm::DialError,
|
||||
) {
|
||||
self.behaviour.inject_addr_reach_failure(peer_id, addr, error)
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
self.behaviour.inject_dial_failure(peer_id)
|
||||
self.behaviour.inject_dial_failure(peer_id, handler, error);
|
||||
}
|
||||
|
||||
fn inject_new_listener(&mut self, id: ListenerId) {
|
||||
|
||||
@@ -26,7 +26,8 @@ use futures::prelude::*;
|
||||
use libp2p::{
|
||||
core::{connection::ConnectionId, ConnectedPoint, Multiaddr, PeerId},
|
||||
swarm::{
|
||||
DialPeerCondition, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
|
||||
DialError, DialPeerCondition, IntoProtocolsHandler, NetworkBehaviour,
|
||||
NetworkBehaviourAction, NotifyHandler, PollParameters,
|
||||
},
|
||||
};
|
||||
use log::{error, trace, warn};
|
||||
@@ -38,7 +39,7 @@ use std::{
|
||||
borrow::Cow,
|
||||
cmp,
|
||||
collections::{hash_map::Entry, VecDeque},
|
||||
error, mem,
|
||||
mem,
|
||||
pin::Pin,
|
||||
str,
|
||||
sync::Arc,
|
||||
@@ -132,7 +133,7 @@ pub struct Notifications {
|
||||
next_incoming_index: sc_peerset::IncomingIndex,
|
||||
|
||||
/// Events to produce from `poll()`.
|
||||
events: VecDeque<NetworkBehaviourAction<NotifsHandlerIn, NotificationsOut>>,
|
||||
events: VecDeque<NetworkBehaviourAction<NotificationsOut, NotifsHandlerProto>>,
|
||||
}
|
||||
|
||||
/// Configuration for a notifications protocol.
|
||||
@@ -628,6 +629,7 @@ impl Notifications {
|
||||
/// Function that is called when the peerset wants us to connect to a peer.
|
||||
fn peerset_report_connect(&mut self, peer_id: PeerId, set_id: sc_peerset::SetId) {
|
||||
// If `PeerId` is unknown to us, insert an entry, start dialing, and return early.
|
||||
let handler = self.new_handler();
|
||||
let mut occ_entry = match self.peers.entry((peer_id, set_id)) {
|
||||
Entry::Occupied(entry) => entry,
|
||||
Entry::Vacant(entry) => {
|
||||
@@ -643,6 +645,7 @@ impl Notifications {
|
||||
self.events.push_back(NetworkBehaviourAction::DialPeer {
|
||||
peer_id: entry.key().0.clone(),
|
||||
condition: DialPeerCondition::Disconnected,
|
||||
handler,
|
||||
});
|
||||
entry.insert(PeerState::Requested);
|
||||
return
|
||||
@@ -679,6 +682,7 @@ impl Notifications {
|
||||
self.events.push_back(NetworkBehaviourAction::DialPeer {
|
||||
peer_id: occ_entry.key().0.clone(),
|
||||
condition: DialPeerCondition::Disconnected,
|
||||
handler,
|
||||
});
|
||||
*occ_entry.into_mut() = PeerState::Requested;
|
||||
},
|
||||
@@ -1094,6 +1098,7 @@ impl NetworkBehaviour for Notifications {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
_failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) {
|
||||
match self.peers.entry((*peer_id, set_id)).or_insert(PeerState::Poisoned) {
|
||||
@@ -1152,6 +1157,7 @@ impl NetworkBehaviour for Notifications {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
_endpoint: &ConnectedPoint,
|
||||
_handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) {
|
||||
let mut entry = if let Entry::Occupied(entry) = self.peers.entry((*peer_id, set_id)) {
|
||||
@@ -1411,70 +1417,74 @@ impl NetworkBehaviour for Notifications {
|
||||
|
||||
fn inject_disconnected(&mut self, _peer_id: &PeerId) {}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
_: Self::ProtocolsHandler,
|
||||
error: &DialError,
|
||||
) {
|
||||
trace!(target: "sub-libp2p", "Libp2p => Reach failure for {:?} through {:?}: {:?}", peer_id, addr, error);
|
||||
}
|
||||
if let DialError::Transport(errors) = error {
|
||||
for (addr, error) in errors.iter() {
|
||||
trace!(target: "sub-libp2p", "Libp2p => Reach failure for {:?} through {:?}: {:?}", peer_id, addr, error);
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
trace!(target: "sub-libp2p", "Libp2p => Dial failure for {:?}", peer_id);
|
||||
if let Some(peer_id) = peer_id {
|
||||
trace!(target: "sub-libp2p", "Libp2p => Dial failure for {:?}", peer_id);
|
||||
|
||||
for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) {
|
||||
if let Entry::Occupied(mut entry) = self.peers.entry((peer_id.clone(), set_id)) {
|
||||
match mem::replace(entry.get_mut(), PeerState::Poisoned) {
|
||||
// The peer is not in our list.
|
||||
st @ PeerState::Backoff { .. } => {
|
||||
*entry.into_mut() = st;
|
||||
},
|
||||
for set_id in (0..self.notif_protocols.len()).map(sc_peerset::SetId::from) {
|
||||
if let Entry::Occupied(mut entry) = self.peers.entry((peer_id.clone(), set_id)) {
|
||||
match mem::replace(entry.get_mut(), PeerState::Poisoned) {
|
||||
// The peer is not in our list.
|
||||
st @ PeerState::Backoff { .. } => {
|
||||
*entry.into_mut() = st;
|
||||
},
|
||||
|
||||
// "Basic" situation: we failed to reach a peer that the peerset requested.
|
||||
st @ PeerState::Requested | st @ PeerState::PendingRequest { .. } => {
|
||||
trace!(target: "sub-libp2p", "PSM <= Dropped({}, {:?})", peer_id, set_id);
|
||||
self.peerset.dropped(set_id, *peer_id, DropReason::Unknown);
|
||||
// "Basic" situation: we failed to reach a peer that the peerset requested.
|
||||
st @ PeerState::Requested | st @ PeerState::PendingRequest { .. } => {
|
||||
trace!(target: "sub-libp2p", "PSM <= Dropped({}, {:?})", peer_id, set_id);
|
||||
self.peerset.dropped(set_id, peer_id, DropReason::Unknown);
|
||||
|
||||
let now = Instant::now();
|
||||
let ban_duration = match st {
|
||||
PeerState::PendingRequest { timer_deadline, .. }
|
||||
if timer_deadline > now =>
|
||||
cmp::max(timer_deadline - now, Duration::from_secs(5)),
|
||||
_ => Duration::from_secs(5),
|
||||
};
|
||||
let now = Instant::now();
|
||||
let ban_duration = match st {
|
||||
PeerState::PendingRequest { timer_deadline, .. }
|
||||
if timer_deadline > now =>
|
||||
cmp::max(timer_deadline - now, Duration::from_secs(5)),
|
||||
_ => Duration::from_secs(5),
|
||||
};
|
||||
|
||||
let delay_id = self.next_delay_id;
|
||||
self.next_delay_id.0 += 1;
|
||||
let delay = futures_timer::Delay::new(ban_duration);
|
||||
let peer_id = *peer_id;
|
||||
self.delays.push(
|
||||
async move {
|
||||
delay.await;
|
||||
(delay_id, peer_id, set_id)
|
||||
}
|
||||
.boxed(),
|
||||
);
|
||||
let delay_id = self.next_delay_id;
|
||||
self.next_delay_id.0 += 1;
|
||||
let delay = futures_timer::Delay::new(ban_duration);
|
||||
let peer_id = peer_id;
|
||||
self.delays.push(
|
||||
async move {
|
||||
delay.await;
|
||||
(delay_id, peer_id, set_id)
|
||||
}
|
||||
.boxed(),
|
||||
);
|
||||
|
||||
*entry.into_mut() = PeerState::Backoff {
|
||||
timer: delay_id,
|
||||
timer_deadline: now + ban_duration,
|
||||
};
|
||||
},
|
||||
*entry.into_mut() = PeerState::Backoff {
|
||||
timer: delay_id,
|
||||
timer_deadline: now + ban_duration,
|
||||
};
|
||||
},
|
||||
|
||||
// We can still get dial failures even if we are already connected to the peer,
|
||||
// as an extra diagnostic for an earlier attempt.
|
||||
st @ PeerState::Disabled { .. } |
|
||||
st @ PeerState::Enabled { .. } |
|
||||
st @ PeerState::DisabledPendingEnable { .. } |
|
||||
st @ PeerState::Incoming { .. } => {
|
||||
*entry.into_mut() = st;
|
||||
},
|
||||
// We can still get dial failures even if we are already connected to the
|
||||
// peer, as an extra diagnostic for an earlier attempt.
|
||||
st @ PeerState::Disabled { .. } |
|
||||
st @ PeerState::Enabled { .. } |
|
||||
st @ PeerState::DisabledPendingEnable { .. } |
|
||||
st @ PeerState::Incoming { .. } => {
|
||||
*entry.into_mut() = st;
|
||||
},
|
||||
|
||||
PeerState::Poisoned => {
|
||||
error!(target: "sub-libp2p", "State of {:?} is poisoned", peer_id);
|
||||
debug_assert!(false);
|
||||
},
|
||||
PeerState::Poisoned => {
|
||||
error!(target: "sub-libp2p", "State of {:?} is poisoned", peer_id);
|
||||
debug_assert!(false);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2000,7 +2010,7 @@ impl NetworkBehaviour for Notifications {
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
_params: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<NotifsHandlerIn, Self::OutEvent>> {
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
if let Some(event) = self.events.pop_front() {
|
||||
return Poll::Ready(event)
|
||||
}
|
||||
@@ -2032,6 +2042,8 @@ impl NetworkBehaviour for Notifications {
|
||||
while let Poll::Ready(Some((delay_id, peer_id, set_id))) =
|
||||
Pin::new(&mut self.delays).poll_next(cx)
|
||||
{
|
||||
let handler = self.new_handler();
|
||||
|
||||
let peer_state = match self.peers.get_mut(&(peer_id, set_id)) {
|
||||
Some(s) => s,
|
||||
// We intentionally never remove elements from `delays`, and it may
|
||||
@@ -2051,6 +2063,7 @@ impl NetworkBehaviour for Notifications {
|
||||
self.events.push_back(NetworkBehaviourAction::DialPeer {
|
||||
peer_id,
|
||||
condition: DialPeerCondition::Disconnected,
|
||||
handler,
|
||||
});
|
||||
*peer_state = PeerState::Requested;
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ use libp2p::{
|
||||
},
|
||||
identity, noise,
|
||||
swarm::{
|
||||
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
DialError, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
ProtocolsHandler, Swarm, SwarmEvent,
|
||||
},
|
||||
yamux, Multiaddr, PeerId, Transport,
|
||||
@@ -68,7 +68,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
in_peers: 25,
|
||||
out_peers: 25,
|
||||
bootnodes: if index == 0 {
|
||||
keypairs.iter().skip(1).map(|keypair| keypair.public().into_peer_id()).collect()
|
||||
keypairs.iter().skip(1).map(|keypair| keypair.public().to_peer_id()).collect()
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
@@ -92,7 +92,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
.enumerate()
|
||||
.filter_map(|(n, a)| {
|
||||
if n != index {
|
||||
Some((keypairs[n].public().into_peer_id(), a.clone()))
|
||||
Some((keypairs[n].public().to_peer_id(), a.clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -100,7 +100,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypairs[index].public().into_peer_id());
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypairs[index].public().to_peer_id());
|
||||
swarm.listen_on(addrs[index].clone()).unwrap();
|
||||
out.push(swarm);
|
||||
}
|
||||
@@ -163,8 +163,10 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
self.inner.inject_connection_established(peer_id, conn, endpoint)
|
||||
self.inner
|
||||
.inject_connection_established(peer_id, conn, endpoint, failed_addresses)
|
||||
}
|
||||
|
||||
fn inject_connection_closed(
|
||||
@@ -172,8 +174,9 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
self.inner.inject_connection_closed(peer_id, conn, endpoint)
|
||||
self.inner.inject_connection_closed(peer_id, conn, endpoint, handler)
|
||||
}
|
||||
|
||||
fn inject_event(
|
||||
@@ -188,27 +191,18 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent
|
||||
>
|
||||
>{
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
self.inner.poll(cx, params)
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
handler: Self::ProtocolsHandler,
|
||||
error: &DialError,
|
||||
) {
|
||||
self.inner.inject_addr_reach_failure(peer_id, addr, error)
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
self.inner.inject_dial_failure(peer_id)
|
||||
self.inner.inject_dial_failure(peer_id, handler, error)
|
||||
}
|
||||
|
||||
fn inject_new_listener(&mut self, id: ListenerId) {
|
||||
|
||||
@@ -45,12 +45,12 @@ use libp2p::{
|
||||
ConnectedPoint, Multiaddr, PeerId,
|
||||
},
|
||||
request_response::{
|
||||
ProtocolSupport, RequestResponse, RequestResponseCodec, RequestResponseConfig,
|
||||
RequestResponseEvent, RequestResponseMessage, ResponseChannel,
|
||||
handler::RequestResponseHandler, ProtocolSupport, RequestResponse, RequestResponseCodec,
|
||||
RequestResponseConfig, RequestResponseEvent, RequestResponseMessage, ResponseChannel,
|
||||
},
|
||||
swarm::{
|
||||
protocols_handler::multi::MultiHandler, NetworkBehaviour, NetworkBehaviourAction,
|
||||
PollParameters, ProtocolsHandler,
|
||||
protocols_handler::multi::MultiHandler, IntoProtocolsHandler, NetworkBehaviour,
|
||||
NetworkBehaviourAction, PollParameters, ProtocolsHandler,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
@@ -377,6 +377,27 @@ impl RequestResponsesBehaviour {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn new_handler_with_replacement(
|
||||
&mut self,
|
||||
protocol: String,
|
||||
handler: RequestResponseHandler<GenericCodec>,
|
||||
) -> <RequestResponsesBehaviour as NetworkBehaviour>::ProtocolsHandler {
|
||||
let mut handlers: HashMap<_, _> = self
|
||||
.protocols
|
||||
.iter_mut()
|
||||
.map(|(p, (r, _))| (p.to_string(), NetworkBehaviour::new_handler(r)))
|
||||
.collect();
|
||||
|
||||
if let Some(h) = handlers.get_mut(&protocol) {
|
||||
*h = handler
|
||||
}
|
||||
|
||||
MultiHandler::try_from_iter(handlers).expect(
|
||||
"Protocols are in a HashMap and there can be at most one handler per protocol name, \
|
||||
which is the only possible error; qed",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
@@ -405,9 +426,16 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
for (p, _) in self.protocols.values_mut() {
|
||||
NetworkBehaviour::inject_connection_established(p, peer_id, conn, endpoint)
|
||||
NetworkBehaviour::inject_connection_established(
|
||||
p,
|
||||
peer_id,
|
||||
conn,
|
||||
endpoint,
|
||||
failed_addresses,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,9 +450,11 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
_handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
for (p, _) in self.protocols.values_mut() {
|
||||
NetworkBehaviour::inject_connection_closed(p, peer_id, conn, endpoint)
|
||||
let handler = p.new_handler();
|
||||
NetworkBehaviour::inject_connection_closed(p, peer_id, conn, endpoint, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,17 +464,6 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
) {
|
||||
for (p, _) in self.protocols.values_mut() {
|
||||
NetworkBehaviour::inject_addr_reach_failure(p, peer_id, addr, error)
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_event(
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
@@ -478,9 +497,15 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<PeerId>,
|
||||
_: Self::ProtocolsHandler,
|
||||
error: &libp2p::swarm::DialError,
|
||||
) {
|
||||
for (p, _) in self.protocols.values_mut() {
|
||||
NetworkBehaviour::inject_dial_failure(p, peer_id)
|
||||
let handler = p.new_handler();
|
||||
NetworkBehaviour::inject_dial_failure(p, peer_id, handler, error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,12 +537,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
>,
|
||||
> {
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
'poll_all: loop {
|
||||
if let Some(message_request) = self.message_request.take() {
|
||||
// Now we can can poll `MessageRequest` until we get the reputation
|
||||
@@ -658,17 +678,26 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
|
||||
// Other events generated by the underlying behaviour are transparently
|
||||
// passed through.
|
||||
NetworkBehaviourAction::DialAddress { address } => {
|
||||
NetworkBehaviourAction::DialAddress { address, handler } => {
|
||||
log::error!(
|
||||
"The request-response isn't supposed to start dialing peers"
|
||||
);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress { address })
|
||||
let protocol = protocol.to_string();
|
||||
let handler = self.new_handler_with_replacement(protocol, handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialAddress {
|
||||
address,
|
||||
handler,
|
||||
})
|
||||
},
|
||||
NetworkBehaviourAction::DialPeer { peer_id, condition } =>
|
||||
NetworkBehaviourAction::DialPeer { peer_id, condition, handler } => {
|
||||
let protocol = protocol.to_string();
|
||||
let handler = self.new_handler_with_replacement(protocol, handler);
|
||||
return Poll::Ready(NetworkBehaviourAction::DialPeer {
|
||||
peer_id,
|
||||
condition,
|
||||
}),
|
||||
handler,
|
||||
})
|
||||
},
|
||||
NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } =>
|
||||
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
|
||||
peer_id,
|
||||
@@ -1061,7 +1090,7 @@ mod tests {
|
||||
|
||||
let behaviour = RequestResponsesBehaviour::new(list, handle).unwrap();
|
||||
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypair.public().into_peer_id());
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypair.public().to_peer_id());
|
||||
let listen_addr: Multiaddr = format!("/memory/{}", rand::random::<u64>()).parse().unwrap();
|
||||
|
||||
swarm.listen_on(listen_addr.clone()).unwrap();
|
||||
|
||||
@@ -56,10 +56,10 @@ use libp2p::{
|
||||
},
|
||||
kad::record,
|
||||
multiaddr,
|
||||
ping::handler::PingFailure,
|
||||
ping::Failure as PingFailure,
|
||||
swarm::{
|
||||
protocols_handler::NodeHandlerWrapperError, AddressScore, NetworkBehaviour, SwarmBuilder,
|
||||
SwarmEvent,
|
||||
protocols_handler::NodeHandlerWrapperError, AddressScore, DialError, NetworkBehaviour,
|
||||
SwarmBuilder, SwarmEvent,
|
||||
},
|
||||
Multiaddr, PeerId,
|
||||
};
|
||||
@@ -176,7 +176,7 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
// Private and public keys configuration.
|
||||
let local_identity = params.network_config.node_key.clone().into_keypair()?;
|
||||
let local_public = local_identity.public();
|
||||
let local_peer_id = local_public.clone().into_peer_id();
|
||||
let local_peer_id = local_public.clone().to_peer_id();
|
||||
info!(
|
||||
target: "sub-libp2p",
|
||||
"🏷 Local node identity is: {}",
|
||||
@@ -1845,8 +1845,13 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
peer_id,
|
||||
endpoint,
|
||||
num_established,
|
||||
concurrent_dial_errors,
|
||||
}) => {
|
||||
debug!(target: "sub-libp2p", "Libp2p => Connected({:?})", peer_id);
|
||||
if let Some(errors) = concurrent_dial_errors {
|
||||
debug!(target: "sub-libp2p", "Libp2p => Connected({:?}) with errors: {:?}", peer_id, errors);
|
||||
} else {
|
||||
debug!(target: "sub-libp2p", "Libp2p => Connected({:?})", peer_id);
|
||||
}
|
||||
|
||||
if let Some(metrics) = this.metrics.as_ref() {
|
||||
let direction = match endpoint {
|
||||
@@ -1914,37 +1919,41 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
metrics.listeners_local_addresses.dec();
|
||||
}
|
||||
},
|
||||
Poll::Ready(SwarmEvent::UnreachableAddr { peer_id, address, error, .. }) => {
|
||||
trace!(
|
||||
target: "sub-libp2p",
|
||||
"Libp2p => Failed to reach {:?} through {:?}: {}",
|
||||
peer_id, address, error,
|
||||
);
|
||||
Poll::Ready(SwarmEvent::OutgoingConnectionError { peer_id, error }) => {
|
||||
if let Some(peer_id) = peer_id {
|
||||
trace!(
|
||||
target: "sub-libp2p",
|
||||
"Libp2p => Failed to reach {:?}: {}",
|
||||
peer_id, error,
|
||||
);
|
||||
|
||||
if this.boot_node_ids.contains(&peer_id) {
|
||||
if let PendingConnectionError::InvalidPeerId = error {
|
||||
error!(
|
||||
"💔 The bootnode you want to connect to at `{}` provided a different peer ID than the one you expect: `{}`.",
|
||||
address, peer_id,
|
||||
);
|
||||
if this.boot_node_ids.contains(&peer_id) {
|
||||
if let DialError::InvalidPeerId = error {
|
||||
error!(
|
||||
"💔 The bootnode you want to connect provided a different peer ID than the one you expect: `{}`.",
|
||||
peer_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(metrics) = this.metrics.as_ref() {
|
||||
match error {
|
||||
PendingConnectionError::ConnectionLimit(_) => metrics
|
||||
let reason = match error {
|
||||
DialError::ConnectionLimit(_) => Some("limit-reached"),
|
||||
DialError::InvalidPeerId => Some("invalid-peer-id"),
|
||||
DialError::Transport(_) | DialError::ConnectionIo(_) =>
|
||||
Some("transport-error"),
|
||||
DialError::Banned |
|
||||
DialError::LocalPeerId |
|
||||
DialError::NoAddresses |
|
||||
DialError::DialPeerConditionFalse(_) |
|
||||
DialError::Aborted => None, // ignore them
|
||||
};
|
||||
if let Some(reason) = reason {
|
||||
metrics
|
||||
.pending_connections_errors_total
|
||||
.with_label_values(&["limit-reached"])
|
||||
.inc(),
|
||||
PendingConnectionError::InvalidPeerId => metrics
|
||||
.pending_connections_errors_total
|
||||
.with_label_values(&["invalid-peer-id"])
|
||||
.inc(),
|
||||
PendingConnectionError::Transport(_) |
|
||||
PendingConnectionError::IO(_) => metrics
|
||||
.pending_connections_errors_total
|
||||
.with_label_values(&["transport-error"])
|
||||
.inc(),
|
||||
.with_label_values(&[reason])
|
||||
.inc();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1970,16 +1979,19 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
);
|
||||
if let Some(metrics) = this.metrics.as_ref() {
|
||||
let reason = match error {
|
||||
PendingConnectionError::ConnectionLimit(_) => "limit-reached",
|
||||
PendingConnectionError::InvalidPeerId => "invalid-peer-id",
|
||||
PendingConnectionError::ConnectionLimit(_) => Some("limit-reached"),
|
||||
PendingConnectionError::InvalidPeerId => Some("invalid-peer-id"),
|
||||
PendingConnectionError::Transport(_) |
|
||||
PendingConnectionError::IO(_) => "transport-error",
|
||||
PendingConnectionError::IO(_) => Some("transport-error"),
|
||||
PendingConnectionError::Aborted => None, // ignore it
|
||||
};
|
||||
|
||||
metrics
|
||||
.incoming_connections_errors_total
|
||||
.with_label_values(&[reason])
|
||||
.inc();
|
||||
if let Some(reason) = reason {
|
||||
metrics
|
||||
.incoming_connections_errors_total
|
||||
.with_label_values(&[reason])
|
||||
.inc();
|
||||
}
|
||||
}
|
||||
},
|
||||
Poll::Ready(SwarmEvent::BannedPeer { peer_id, endpoint }) => {
|
||||
@@ -1995,9 +2007,6 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
.inc();
|
||||
}
|
||||
},
|
||||
Poll::Ready(SwarmEvent::UnknownPeerUnreachableAddr { address, error }) => {
|
||||
trace!(target: "sub-libp2p", "Libp2p => UnknownPeerUnreachableAddr({}): {}", address, error)
|
||||
},
|
||||
Poll::Ready(SwarmEvent::ListenerClosed { reason, addresses, .. }) => {
|
||||
if let Some(metrics) = this.metrics.as_ref() {
|
||||
metrics.listeners_local_addresses.sub(addresses.len() as u64);
|
||||
|
||||
@@ -20,7 +20,7 @@ parking_lot = "0.11.1"
|
||||
futures = "0.3.9"
|
||||
futures-timer = "3.0.1"
|
||||
rand = "0.7.2"
|
||||
libp2p = { version = "0.39.1", default-features = false }
|
||||
libp2p = { version = "0.40.0", default-features = false }
|
||||
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
|
||||
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
|
||||
sc-client-api = { version = "4.0.0-dev", path = "../../api" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.9"
|
||||
libp2p = { version = "0.39.1", default-features = false }
|
||||
libp2p = { version = "0.40.0", default-features = false }
|
||||
sc-utils = { version = "4.0.0-dev", path = "../utils"}
|
||||
log = "0.4.8"
|
||||
serde_json = "1.0.71"
|
||||
|
||||
@@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
parking_lot = "0.11.1"
|
||||
futures = "0.3.9"
|
||||
wasm-timer = "0.2.5"
|
||||
libp2p = { version = "0.39.1", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] }
|
||||
libp2p = { version = "0.40.0", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] }
|
||||
log = "0.4.8"
|
||||
pin-project = "1.0.8"
|
||||
rand = "0.7.2"
|
||||
|
||||
Reference in New Issue
Block a user