Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 5104f88

Browse files
author
Roman S. Borschel
committed
Further adapt to libp2p/master.
1 parent 244935a commit 5104f88

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ panic = "unwind"
176176

177177
[patch.crates-io]
178178
# libp2p = { path = "../rust-libp2p" }
179-
libp2p = { git = "https://github.com/romanb/rust-libp2p", branch = "multicon" }
179+
libp2p = { git = "https://github.com/libp2p/rust-libp2p", branch = "master" }
180+
libp2p-wasm-ext = { git = "https://github.com/libp2p/rust-libp2p", branch = "master" }
180181

181182

client/authority-discovery/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ where
312312
.map_err(Error::EncodingProto)?;
313313

314314
self.network.put_value(
315-
hash_authority_id(key.1.as_ref())?,
315+
hash_authority_id(key.1.as_ref()),
316316
signed_addresses,
317317
);
318318
}
@@ -335,7 +335,7 @@ where
335335

336336
for authority_id in authorities.iter() {
337337
self.network
338-
.get_value(&hash_authority_id(authority_id.as_ref())?);
338+
.get_value(&hash_authority_id(authority_id.as_ref()));
339339
}
340340

341341
Ok(())
@@ -420,8 +420,8 @@ where
420420
self.addr_cache.retain_ids(&authorities);
421421
authorities
422422
.into_iter()
423-
.map(|id| hash_authority_id(id.as_ref()).map(|h| (h, id)))
424-
.collect::<Result<HashMap<_, _>>>()?
423+
.map(|id| (hash_authority_id(id.as_ref()), id))
424+
.collect::<HashMap<_, _>>()
425425
};
426426

427427
// Check if the event origins from an authority in the current authority set.
@@ -598,10 +598,8 @@ where
598598
}
599599
}
600600

601-
fn hash_authority_id(id: &[u8]) -> Result<libp2p::kad::record::Key> {
602-
libp2p::multihash::encode(libp2p::multihash::Hash::SHA2256, id)
603-
.map(|k| libp2p::kad::record::Key::new(&k))
604-
.map_err(Error::HashingAuthorityId)
601+
fn hash_authority_id(id: &[u8]) -> libp2p::kad::record::Key {
602+
libp2p::kad::record::Key::new(&libp2p::multihash::Sha2_256::digest(id))
605603
}
606604

607605
fn interval_at(start: Instant, duration: Duration) -> Interval {

client/authority-discovery/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ fn handle_dht_events_with_value_found_should_call_set_priority_group() {
303303

304304
// Create sample dht event.
305305

306-
let authority_id_1 = hash_authority_id(key_pair.public().as_ref()).unwrap();
306+
let authority_id_1 = hash_authority_id(key_pair.public().as_ref());
307307
let address_1: Multiaddr = "/ip6/2001:db8::".parse().unwrap();
308308

309309
let mut serialized_addresses = vec![];

client/network-gossip/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ documentation = "https://docs.rs/sc-network-gossip"
1313
[dependencies]
1414
futures = "0.3.4"
1515
futures-timer = "3.0.1"
16-
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
16+
libp2p = { version = "0.16.2", default-features = false, features = ["websocket"] }
1717
log = "0.4.8"
1818
lru = "0.4.3"
1919
sc-network = { version = "0.8.0-alpha.5", path = "../network" }

client/network/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ futures = "0.3.4"
2626
futures_codec = "0.3.3"
2727
futures-timer = "3.0.1"
2828
wasm-timer = "0.2"
29-
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
3029
linked-hash-map = "0.5.2"
3130
linked_hash_set = "0.1.3"
3231
log = "0.4.8"
@@ -58,10 +57,16 @@ unsigned-varint = { version = "0.3.1", features = ["futures", "futures-codec"] }
5857
void = "1.0.2"
5958
zeroize = "1.0.0"
6059

60+
[dependencies.libp2p]
61+
version = "0.16.2"
62+
default-features = false
63+
features = ["websocket", "kad", "mdns", "ping", "identify", "mplex", "yamux", "noise"]
64+
6165
[dev-dependencies]
6266
async-std = "1.5"
6367
assert_matches = "1.3"
6468
env_logger = "0.7.0"
69+
libp2p = { version = "0.16.2", default-features = false, features = ["secio"] }
6570
quickcheck = "0.9.0"
6671
rand = "0.7.2"
6772
sp-keyring = { version = "2.0.0-alpha.5", path = "../../primitives/keyring" }

client/telemetry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parking_lot = "0.10.0"
1616
futures = "0.3.4"
1717
futures-timer = "3.0.1"
1818
wasm-timer = "0.2.0"
19-
libp2p = { version = "0.16.2", default-features = false, features = ["libp2p-websocket"] }
19+
libp2p = { version = "0.16.2", default-features = false, features = ["websocket", "wasm-ext", "tcp", "dns"] }
2020
log = "0.4.8"
2121
pin-project = "0.4.6"
2222
rand = "0.7.2"

0 commit comments

Comments
 (0)