mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
*: Update to libp2p v0.21.1 (#6559)
* *Cargo.toml: Update versions * client/network/src/discovery: Adjust to Kademlia API changes * client/network: Adjust to one_shot.rs changes * client/network/discovery: Log address list on trace level * client/network/discovery: Ignore RoutablePeer and PendingRoutablePeer * Commit Cargo.lock * Finish update Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
Generated
+111
-65
@@ -225,39 +225,33 @@ checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5"
|
||||
|
||||
[[package]]
|
||||
name = "async-std"
|
||||
version = "1.5.0"
|
||||
version = "1.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267"
|
||||
checksum = "00d68a33ebc8b57800847d00787307f84a562224a14db069b0acefe4c2abbf5d"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"broadcaster",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-timer 2.0.2",
|
||||
"futures-timer 3.0.2",
|
||||
"kv-log-macro",
|
||||
"log",
|
||||
"memchr",
|
||||
"mio",
|
||||
"mio-uds",
|
||||
"num_cpus",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
"smol",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-task"
|
||||
version = "1.3.1"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3"
|
||||
|
||||
[[package]]
|
||||
name = "async-tls"
|
||||
@@ -465,17 +459,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "broadcaster"
|
||||
version = "1.0.0"
|
||||
name = "blocking"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87"
|
||||
checksum = "9d17efb70ce4421e351d61aafd90c16a20fb5bfe339fcdc32a86816280e62ce0"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"parking_lot 0.10.2",
|
||||
"slab",
|
||||
"once_cell",
|
||||
"parking",
|
||||
"waker-fn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -552,6 +545,12 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b"
|
||||
|
||||
[[package]]
|
||||
name = "cache-padded"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24508e28c677875c380c20f4d28124fab6f8ed4ef929a1397d7b1a31e92f1005"
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.10.0"
|
||||
@@ -699,6 +698,15 @@ dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83c06aff61f2d899eb87c379df3cbf7876f14471dcab474e0b6dc90ab96c080"
|
||||
dependencies = [
|
||||
"cache-padded",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
@@ -935,16 +943,6 @@ dependencies = [
|
||||
"itertools 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.7.3"
|
||||
@@ -1384,6 +1382,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b90eb1dec02087df472ab9f0db65f27edaa654a746830042688bcc2eaf68090f"
|
||||
|
||||
[[package]]
|
||||
name = "fdlimit"
|
||||
version = "0.1.4"
|
||||
@@ -2715,9 +2719,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.69"
|
||||
version = "0.2.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
|
||||
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
|
||||
|
||||
[[package]]
|
||||
name = "libflate"
|
||||
@@ -2749,9 +2753,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
||||
|
||||
[[package]]
|
||||
name = "libp2p"
|
||||
version = "0.20.1"
|
||||
version = "0.21.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db81113df355dea9dddfcb01cd867555298dca29d915f25d1b1a0aad2e29338b"
|
||||
checksum = "6d743d03fab397cde23925a17cb87b35b25994f44ab8c6a9e46a7e953ec739cd"
|
||||
dependencies = [
|
||||
"bytes 0.5.4",
|
||||
"futures 0.3.5",
|
||||
@@ -2781,9 +2785,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-core"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a0387b930c3d4c2533dc4893c1e0394185ddcc019846121b1b27491e45a2c08"
|
||||
checksum = "11ca8d5a64a5d19b45e00e8f24afda6b8e1b605fb25ad7bcf62a42ecf19d7ff3"
|
||||
dependencies = [
|
||||
"asn1_der",
|
||||
"bs58",
|
||||
@@ -2815,9 +2819,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-core-derive"
|
||||
version = "0.19.1"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f09548626b737ed64080fde595e06ce1117795b8b9fc4d2629fa36561c583171"
|
||||
checksum = "4b2f4f7b4e596450a0b62a46669caaebab9686c68b3c386053182ab41d761f66"
|
||||
dependencies = [
|
||||
"quote 1.0.6",
|
||||
"syn 1.0.33",
|
||||
@@ -2825,9 +2829,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-dns"
|
||||
version = "0.19.0"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3cc186d9a941fd0207cf8f08ef225a735e2d7296258f570155e525f6ee732f87"
|
||||
checksum = "f751924b6b98e350005e0b87a822beb246792a3fb878c684e088f866158120ac"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"libp2p-core",
|
||||
@@ -2836,9 +2840,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-identify"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62f76075b170d908bae616f550ade410d9d27c013fa69042551dbfc757c7c094"
|
||||
checksum = "912c00a7bf67e0e765daf0cc37e08f675ea26aba3d6d1fbfaee81f19a4c23049"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"libp2p-core",
|
||||
@@ -2852,9 +2856,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-kad"
|
||||
version = "0.20.1"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7c819a5425b2eb3416d67e9c868c5c1e922b6658655e06b9eeafaa41304b876"
|
||||
checksum = "44ed3a4c8111c570ab2bffb30c6353178d7603ce3787e3c5f2493c8d3d16d1f0"
|
||||
dependencies = [
|
||||
"arrayvec 0.5.1",
|
||||
"bytes 0.5.4",
|
||||
@@ -2879,9 +2883,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mdns"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f55b2d4b80986e5bf158270ab23268ec0e7f644ece5436fbaabc5155472f357"
|
||||
checksum = "cd004c668160fd922f7268b2cd1e4550ff69165d9c744e9eb5770086eb753d02"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"data-encoding",
|
||||
@@ -2901,9 +2905,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mplex"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be7d913a4cd57de2013257ec73f07d77bfce390b370023e2d59083e5ca079864"
|
||||
checksum = "14ae0ffacd30f073f96cd518b2c9cd2cb18ac27c3d136a4b23cf1af99f33e541"
|
||||
dependencies = [
|
||||
"bytes 0.5.4",
|
||||
"fnv",
|
||||
@@ -2917,9 +2921,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-noise"
|
||||
version = "0.19.1"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a03db664653369f46ee03fcec483a378c20195089bb43a26cb9fb0058009ac88"
|
||||
checksum = "f6ad6b67d802de8b5ddc5e8b0ff55a0d0a6a737c2c5c174601dbb9d24e0ad5cb"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"futures 0.3.5",
|
||||
@@ -2938,9 +2942,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-ping"
|
||||
version = "0.19.3"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8dedd34e35a9728d52d59ef36a218e411359a353f9011b2574b86ee790978f6"
|
||||
checksum = "70130cf130e4ba6dc177366e72dd9f86f9e3588fa1a0c4145247e676f16affad"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"libp2p-core",
|
||||
@@ -2953,9 +2957,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-secio"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c99b3c33e96bb402486d5b4f7cbeab14e66e6a2ed010abbb5bb032a05460bfda"
|
||||
checksum = "5ff43513c383f7cdab2736eb98465fc4c5dd5d1988df89749dc8a68950349d56"
|
||||
dependencies = [
|
||||
"aes-ctr",
|
||||
"ctr",
|
||||
@@ -2983,9 +2987,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-swarm"
|
||||
version = "0.19.1"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce53ff4d127cf8b39adf84dbd381ca32d49bd85788cee08e6669da2495993930"
|
||||
checksum = "3829b323fe096a9363362d0dbbfb3d73f12f1760a6a5c193a779994ab8cbc584"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"libp2p-core",
|
||||
@@ -2998,9 +3002,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-tcp"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9481500c5774c62e8c413e9535b3f33a0e3dbacf2da63b8d3056c686a9df4146"
|
||||
checksum = "9b1fa2bbad054020cb875546a577a66a65a5bf42eff55ed5265f92ffee3cc052"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"futures 0.3.5",
|
||||
@@ -3014,9 +3018,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-wasm-ext"
|
||||
version = "0.19.0"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59fdbb5706f2723ca108c088b1c7a37f735a8c328021f0508007162627e9885"
|
||||
checksum = "1e2b3f0281c184af2e3481ad2463682735d491b2ceb8f73fa99dcd5d41e7afbf"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"js-sys",
|
||||
@@ -3028,9 +3032,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-websocket"
|
||||
version = "0.20.0"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e4440551bf6519e0a684cd859ea809aec6d798f686e0d6ed03a28c3e76849b8"
|
||||
checksum = "bd3a13025c0f621647ed2c5147615468e7b3cd1a5c7f26f2a6f6f8eafc9c1950"
|
||||
dependencies = [
|
||||
"async-tls",
|
||||
"either",
|
||||
@@ -3048,9 +3052,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-yamux"
|
||||
version = "0.19.1"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8da33e7b5f49c75c6a8afb0b8d1e229f5fa48be9f39bd14cdbc21459a02ac6fc"
|
||||
checksum = "46ae9bf2f7d8a4be9c7e9b61df9de9dc1bd66419d669098f22f81f8d9571029a"
|
||||
dependencies = [
|
||||
"futures 0.3.5",
|
||||
"libp2p-core",
|
||||
@@ -5052,6 +5056,12 @@ version = "0.41.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4029bc3504a62d92e42f30b9095fdef73b8a0b2a06aa41ce2935143b05a1a06"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.9.0"
|
||||
@@ -7429,6 +7439,27 @@ version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
|
||||
|
||||
[[package]]
|
||||
name = "smol"
|
||||
version = "0.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"blocking",
|
||||
"concurrent-queue",
|
||||
"fastrand",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"scoped-tls",
|
||||
"slab",
|
||||
"socket2",
|
||||
"wepoll-sys-stjepang",
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "snow"
|
||||
version = "0.7.0"
|
||||
@@ -9493,6 +9524,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "waker-fn"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9571542c2ce85ce642e6b58b3364da2fb53526360dfb7c211add4f5c23105ff7"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.1"
|
||||
@@ -9787,6 +9824,15 @@ dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wepoll-sys-stjepang"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "3.1.1"
|
||||
|
||||
@@ -8,7 +8,7 @@ license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
futures-timer = "3.0.2"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
jsonrpc-core = "14.2.0"
|
||||
serde = "1.0.106"
|
||||
serde_json = "1.0.48"
|
||||
|
||||
@@ -33,7 +33,7 @@ derive_more = { version = "0.99.2" }
|
||||
sc-rpc = { version = "2.0.0-rc4", path = "../../../client/rpc" }
|
||||
jsonrpc-core-client = { version = "14.2.0", features = ["http"] }
|
||||
hyper = "0.12.35"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
serde_json = "1.0"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -21,7 +21,7 @@ codec = { package = "parity-scale-codec", default-features = false, version = "1
|
||||
derive_more = "0.99.2"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
libp2p = { version = "0.20.1", default-features = false, features = ["kad"] }
|
||||
libp2p = { version = "0.21.1", default-features = false, features = ["kad"] }
|
||||
log = "0.4.8"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0-rc4"}
|
||||
prost = "0.6.1"
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
log = "0.4.8"
|
||||
lru = "0.4.3"
|
||||
sc-network = { version = "0.8.0-rc4", path = "../network" }
|
||||
@@ -24,7 +24,7 @@ sp-runtime = { version = "2.0.0-rc4", path = "../../primitives/runtime" }
|
||||
wasm-timer = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
async-std = "1.5"
|
||||
async-std = "1.6.2"
|
||||
quickcheck = "0.9.0"
|
||||
rand = "0.7.2"
|
||||
substrate-test-runtime-client = { version = "2.0.0-rc4", path = "../../test-utils/runtime/client" }
|
||||
|
||||
@@ -63,15 +63,15 @@ wasm-timer = "0.2"
|
||||
zeroize = "1.0.0"
|
||||
|
||||
[dependencies.libp2p]
|
||||
version = "0.20.1"
|
||||
version = "0.21.1"
|
||||
default-features = false
|
||||
features = ["identify", "kad", "mdns", "mplex", "noise", "ping", "tcp-async-std", "websocket", "yamux"]
|
||||
|
||||
[dev-dependencies]
|
||||
async-std = "1.5"
|
||||
async-std = "1.6.2"
|
||||
assert_matches = "1.3"
|
||||
env_logger = "0.7.0"
|
||||
libp2p = { version = "0.20.1", default-features = false, features = ["secio"] }
|
||||
libp2p = { version = "0.21.1", default-features = false, features = ["secio"] }
|
||||
quickcheck = "0.9.0"
|
||||
rand = "0.7.2"
|
||||
sp-keyring = { version = "2.0.0-rc4", path = "../../primitives/keyring" }
|
||||
|
||||
@@ -29,7 +29,13 @@ use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess, PollPa
|
||||
use log::debug;
|
||||
use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
|
||||
use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId, Justification};
|
||||
use std::{borrow::Cow, collections::VecDeque, iter, task::{Context, Poll}, time::Duration};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{HashSet, VecDeque},
|
||||
iter,
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
/// General behaviour of the network. Combines all protocols together.
|
||||
#[derive(NetworkBehaviour)]
|
||||
@@ -124,7 +130,7 @@ impl<B: BlockT, H: ExHashT> Behaviour<B, H> {
|
||||
}
|
||||
|
||||
/// Returns the list of nodes that we know exist in the network.
|
||||
pub fn known_peers(&mut self) -> impl Iterator<Item = &PeerId> {
|
||||
pub fn known_peers(&mut self) -> HashSet<PeerId> {
|
||||
self.discovery.known_peers()
|
||||
}
|
||||
|
||||
|
||||
@@ -455,8 +455,8 @@ where
|
||||
marker: PhantomData,
|
||||
};
|
||||
let mut cfg = OneShotHandlerConfig::default();
|
||||
cfg.inactive_timeout = self.config.inactivity_timeout;
|
||||
cfg.substream_timeout = self.config.request_timeout;
|
||||
cfg.keep_alive_timeout = self.config.inactivity_timeout;
|
||||
cfg.outbound_substream_timeout = self.config.request_timeout;
|
||||
OneShotHandler::new(SubstreamProtocol::new(p), cfg)
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ impl DiscoveryConfig {
|
||||
{
|
||||
for (peer_id, addr) in user_defined {
|
||||
for kad in self.kademlias.values_mut() {
|
||||
kad.add_address(&peer_id, addr.clone())
|
||||
kad.add_address(&peer_id, addr.clone());
|
||||
}
|
||||
self.user_defined.push((peer_id, addr))
|
||||
}
|
||||
@@ -230,12 +230,18 @@ pub struct DiscoveryBehaviour {
|
||||
|
||||
impl DiscoveryBehaviour {
|
||||
/// Returns the list of nodes that we know exist in the network.
|
||||
pub fn known_peers(&mut self) -> impl Iterator<Item = &PeerId> {
|
||||
let mut set = HashSet::new();
|
||||
for p in self.kademlias.values_mut().map(|k| k.kbuckets_entries()).flatten() {
|
||||
set.insert(p);
|
||||
pub fn known_peers(&mut self) -> HashSet<PeerId> {
|
||||
let mut peers = HashSet::new();
|
||||
for k in self.kademlias.values_mut() {
|
||||
for b in k.kbuckets() {
|
||||
for e in b.iter() {
|
||||
if !peers.contains(e.node.key.preimage()) {
|
||||
peers.insert(e.node.key.preimage().clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
set.into_iter()
|
||||
peers
|
||||
}
|
||||
|
||||
/// Adds a hard-coded address for the given peer, that never expires.
|
||||
@@ -246,7 +252,7 @@ impl DiscoveryBehaviour {
|
||||
pub fn add_known_address(&mut self, peer_id: PeerId, addr: Multiaddr) {
|
||||
if self.user_defined.iter().all(|(p, a)| *p != peer_id && *a != addr) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
k.add_address(&peer_id, addr.clone())
|
||||
k.add_address(&peer_id, addr.clone());
|
||||
}
|
||||
self.pending_events.push_back(DiscoveryOut::Discovered(peer_id.clone()));
|
||||
self.user_defined.push((peer_id, addr));
|
||||
@@ -260,7 +266,7 @@ impl DiscoveryBehaviour {
|
||||
pub fn add_self_reported_address(&mut self, peer_id: &PeerId, addr: Multiaddr) {
|
||||
if self.allow_non_globals_in_dht || self.can_add_to_dht(&addr) {
|
||||
for k in self.kademlias.values_mut() {
|
||||
k.add_address(peer_id, addr.clone())
|
||||
k.add_address(peer_id, addr.clone());
|
||||
}
|
||||
} else {
|
||||
log::trace!(target: "sub-libp2p", "Ignoring self-reported address {} from {}", addr, peer_id);
|
||||
@@ -291,7 +297,8 @@ impl DiscoveryBehaviour {
|
||||
|
||||
/// Returns the number of nodes that are in the Kademlia k-buckets.
|
||||
pub fn num_kbuckets_entries(&mut self) -> impl ExactSizeIterator<Item = (&ProtocolId, usize)> {
|
||||
self.kademlias.iter_mut().map(|(id, kad)| (id, kad.kbuckets_entries().count()))
|
||||
self.kademlias.iter_mut()
|
||||
.map(|(id, kad)| (id, kad.kbuckets().map(|bucket| bucket.iter().count()).sum()))
|
||||
}
|
||||
|
||||
/// Returns the number of records in the Kademlia record stores.
|
||||
@@ -407,23 +414,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
list.extend(list_to_filter);
|
||||
}
|
||||
|
||||
if !list.is_empty() {
|
||||
trace!(target: "sub-libp2p", "Addresses of {:?}: {:?}", peer_id, list);
|
||||
|
||||
} else {
|
||||
let mut has_entry = false;
|
||||
for k in self.kademlias.values_mut() {
|
||||
if k.kbuckets_entries().any(|p| p == peer_id) {
|
||||
has_entry = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
if has_entry {
|
||||
trace!(target: "sub-libp2p", "Addresses of {:?}: none (peer in k-buckets)", peer_id);
|
||||
} else {
|
||||
trace!(target: "sub-libp2p", "Addresses of {:?}: none (peer not in k-buckets)", peer_id);
|
||||
}
|
||||
}
|
||||
trace!(target: "sub-libp2p", "Addresses of {:?}: {:?}", peer_id, list);
|
||||
|
||||
list
|
||||
}
|
||||
@@ -570,13 +561,16 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
while let Poll::Ready(ev) = kademlia.poll(cx, params) {
|
||||
match ev {
|
||||
NetworkBehaviourAction::GenerateEvent(ev) => match ev {
|
||||
KademliaEvent::RoutingUpdated { peer, .. } => {
|
||||
let ev = DiscoveryOut::Discovered(peer);
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev));
|
||||
}
|
||||
KademliaEvent::UnroutablePeer { peer, .. } => {
|
||||
let ev = DiscoveryOut::UnroutablePeer(peer);
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev));
|
||||
}
|
||||
KademliaEvent::RoutingUpdated { peer, .. } => {
|
||||
let ev = DiscoveryOut::Discovered(peer);
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev));
|
||||
KademliaEvent::RoutablePeer { .. } | KademliaEvent::PendingRoutablePeer { .. } => {
|
||||
// We are not interested in these events at the moment.
|
||||
}
|
||||
KademliaEvent::QueryResult { result: QueryResult::GetClosestPeers(res), .. } => {
|
||||
match res {
|
||||
@@ -640,9 +634,6 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
e.key(), e)
|
||||
}
|
||||
}
|
||||
KademliaEvent::Discovered { .. } => {
|
||||
// We are not interested in these events at the moment.
|
||||
}
|
||||
// We never start any other type of query.
|
||||
e => {
|
||||
warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e)
|
||||
|
||||
@@ -234,7 +234,7 @@ where
|
||||
marker: PhantomData,
|
||||
};
|
||||
let mut cfg = OneShotHandlerConfig::default();
|
||||
cfg.inactive_timeout = self.config.inactivity_timeout;
|
||||
cfg.keep_alive_timeout = self.config.inactivity_timeout;
|
||||
OneShotHandler::new(SubstreamProtocol::new(p), cfg)
|
||||
}
|
||||
|
||||
|
||||
@@ -757,7 +757,7 @@ where
|
||||
protocol: self.config.light_protocol.clone(),
|
||||
};
|
||||
let mut cfg = OneShotHandlerConfig::default();
|
||||
cfg.inactive_timeout = self.config.inactivity_timeout;
|
||||
cfg.keep_alive_timeout = self.config.inactivity_timeout;
|
||||
OneShotHandler::new(SubstreamProtocol::new(p), cfg)
|
||||
}
|
||||
|
||||
|
||||
@@ -490,17 +490,18 @@ impl<B: BlockT + 'static, H: ExHashT> NetworkWorker<B, H> {
|
||||
|
||||
let not_connected_peers = {
|
||||
let swarm = &mut *swarm;
|
||||
let list = swarm.known_peers().filter(|p| open.iter().all(|n| n != *p))
|
||||
.cloned().collect::<Vec<_>>();
|
||||
list.into_iter().map(move |peer_id| {
|
||||
(peer_id.to_base58(), NetworkStateNotConnectedPeer {
|
||||
version_string: swarm.node(&peer_id)
|
||||
.and_then(|i| i.client_version().map(|s| s.to_owned())),
|
||||
latest_ping_time: swarm.node(&peer_id).and_then(|i| i.latest_ping()),
|
||||
known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
|
||||
.into_iter().collect(),
|
||||
swarm.known_peers().into_iter()
|
||||
.filter(|p| open.iter().all(|n| n != p))
|
||||
.map(move |peer_id| {
|
||||
(peer_id.to_base58(), NetworkStateNotConnectedPeer {
|
||||
version_string: swarm.node(&peer_id)
|
||||
.and_then(|i| i.client_version().map(|s| s.to_owned())),
|
||||
latest_ping_time: swarm.node(&peer_id).and_then(|i| i.latest_ping()),
|
||||
known_addresses: NetworkBehaviour::addresses_of_peer(&mut **swarm, &peer_id)
|
||||
.into_iter().collect(),
|
||||
})
|
||||
})
|
||||
}).collect()
|
||||
.collect()
|
||||
};
|
||||
|
||||
NetworkState {
|
||||
|
||||
@@ -19,7 +19,7 @@ parking_lot = "0.10.0"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
rand = "0.7.2"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
sp-consensus = { version = "0.8.0-rc4", path = "../../../primitives/consensus/common" }
|
||||
sc-consensus = { version = "0.8.0-rc4", path = "../../../client/consensus/common" }
|
||||
sc-client-api = { version = "2.0.0-rc4", path = "../../api" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.4"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
sp-utils = { version = "2.0.0-rc4", path = "../../primitives/utils"}
|
||||
log = "0.4.8"
|
||||
serde_json = "1.0.41"
|
||||
|
||||
@@ -18,7 +18,7 @@ parking_lot = "0.10.0"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
wasm-timer = "0.2.0"
|
||||
libp2p = { version = "0.20.1", default-features = false, features = ["dns", "tcp-async-std", "wasm-ext", "websocket"] }
|
||||
libp2p = { version = "0.21.1", default-features = false, features = ["dns", "tcp-async-std", "wasm-ext", "websocket"] }
|
||||
log = "0.4.8"
|
||||
pin-project = "0.4.6"
|
||||
rand = "0.7.2"
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
derive_more = "0.99.2"
|
||||
libp2p = { version = "0.20.1", default-features = false }
|
||||
libp2p = { version = "0.21.1", default-features = false }
|
||||
log = "0.4.8"
|
||||
sp-core = { path= "../../core", version = "2.0.0-rc4"}
|
||||
sp-inherents = { version = "2.0.0-rc4", path = "../../inherents" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
futures = { version = "0.3", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
log = "0.4.8"
|
||||
libp2p-wasm-ext = { version = "0.19.0", features = ["websocket"] }
|
||||
libp2p-wasm-ext = { version = "0.20", features = ["websocket"] }
|
||||
console_error_panic_hook = "0.1.6"
|
||||
console_log = "0.1.2"
|
||||
js-sys = "0.3.34"
|
||||
|
||||
@@ -18,7 +18,6 @@ futures-util = { version = "0.3.1", default-features = false, features = ["io"]
|
||||
derive_more = "0.99"
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
# async-std is temporarily pinned to <1.6 because version 1.6.0 is buggy
|
||||
async-std = { version = "1.0.1, <1.6", features = ["unstable"] }
|
||||
async-std = { version = "1.6.2", features = ["unstable"] }
|
||||
hyper = { version = "0.13.1", default-features = false, features = ["stream"] }
|
||||
tokio = "0.2"
|
||||
|
||||
Reference in New Issue
Block a user