*: Update to libp2p v0.33.0 (#7759)

* *: Update to libp2p v0.33.0

* client/network: Consistently track request arrival time

With https://github.com/libp2p/rust-libp2p/pull/1886/ one is guaranteed
to receive either a `ResponseSent` or a `InboundFailure` event for each
received inbound request via `RequestResponseEvent::Message`. Given this
guarantee there is no need to track arrival times in a best-effort
manner and thus there is no need to use a LRU cache for arrival times.

* client/offchain: Adjust to PeerId API changes
This commit is contained in:
Max Inden
2021-01-04 12:54:51 +01:00
committed by GitHub
parent 51c37ecc15
commit f0b99dd2f2
15 changed files with 88 additions and 91 deletions
+4 -4
View File
@@ -187,9 +187,9 @@ impl<Storage: OffchainStorage> OffchainExt for Api<Storage> {
fn set_authorized_nodes(&mut self, nodes: Vec<OpaquePeerId>, authorized_only: bool) {
let peer_ids: HashSet<PeerId> = nodes.into_iter()
.filter_map(|node| PeerId::from_bytes(node.0).ok())
.filter_map(|node| PeerId::from_bytes(&node.0).ok())
.collect();
self.network_provider.set_authorized_peers(peer_ids);
self.network_provider.set_authorized_only(authorized_only);
}
@@ -213,7 +213,7 @@ impl NetworkState {
impl From<NetworkState> for OpaqueNetworkState {
fn from(state: NetworkState) -> OpaqueNetworkState {
let enc = Encode::encode(&state.peer_id.into_bytes());
let enc = Encode::encode(&state.peer_id.to_bytes());
let peer_id = OpaquePeerId::new(enc);
let external_addresses: Vec<OpaqueMultiaddr> = state
@@ -239,7 +239,7 @@ impl TryFrom<OpaqueNetworkState> for NetworkState {
let inner_vec = state.peer_id.0;
let bytes: Vec<u8> = Decode::decode(&mut &inner_vec[..]).map_err(|_| ())?;
let peer_id = PeerId::from_bytes(bytes).map_err(|_| ())?;
let peer_id = PeerId::from_bytes(&bytes).map_err(|_| ())?;
let external_addresses: Result<Vec<Multiaddr>, Self::Error> = state.external_addresses
.iter()