mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
libp2p-next (#5278)
* Adapt to rust-libp2p#1440. * Further adapt to libp2p/master. * Update to libp2p-0.17 * Finishing touches. * Remove stray TODO. * Incorporate review feedback. * Remove unused import.
This commit is contained in:
@@ -300,7 +300,7 @@ where
|
||||
.map_err(Error::EncodingProto)?;
|
||||
|
||||
self.network.put_value(
|
||||
hash_authority_id(key.1.as_ref())?,
|
||||
hash_authority_id(key.1.as_ref()),
|
||||
signed_addresses,
|
||||
);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ where
|
||||
|
||||
for authority_id in authorities.iter() {
|
||||
self.network
|
||||
.get_value(&hash_authority_id(authority_id.as_ref())?);
|
||||
.get_value(&hash_authority_id(authority_id.as_ref()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -408,8 +408,8 @@ where
|
||||
self.addr_cache.retain_ids(&authorities);
|
||||
authorities
|
||||
.into_iter()
|
||||
.map(|id| hash_authority_id(id.as_ref()).map(|h| (h, id)))
|
||||
.collect::<Result<HashMap<_, _>>>()?
|
||||
.map(|id| (hash_authority_id(id.as_ref()), id))
|
||||
.collect::<HashMap<_, _>>()
|
||||
};
|
||||
|
||||
// Check if the event origins from an authority in the current authority set.
|
||||
@@ -586,10 +586,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn hash_authority_id(id: &[u8]) -> Result<libp2p::kad::record::Key> {
|
||||
libp2p::multihash::encode(libp2p::multihash::Hash::SHA2256, id)
|
||||
.map(|k| libp2p::kad::record::Key::new(&k))
|
||||
.map_err(Error::HashingAuthorityId)
|
||||
fn hash_authority_id(id: &[u8]) -> libp2p::kad::record::Key {
|
||||
libp2p::kad::record::Key::new(&libp2p::multihash::Sha2_256::digest(id))
|
||||
}
|
||||
|
||||
fn interval_at(start: Instant, duration: Duration) -> Interval {
|
||||
|
||||
@@ -304,7 +304,7 @@ fn handle_dht_events_with_value_found_should_call_set_priority_group() {
|
||||
|
||||
// Create sample dht event.
|
||||
|
||||
let authority_id_1 = hash_authority_id(key_pair.public().as_ref()).unwrap();
|
||||
let authority_id_1 = hash_authority_id(key_pair.public().as_ref());
|
||||
let address_1: Multiaddr = "/ip6/2001:db8::".parse().unwrap();
|
||||
|
||||
let mut serialized_addresses = vec![];
|
||||
|
||||
Reference in New Issue
Block a user