feat: leverage type-safe /p2p in multiaddr

This updates `multiaddr` to version `0.19`.

Depends-On: #3656.
Depends-On: https://github.com/multiformats/rust-multiaddr/pull/83.
Resolves: #4039.

Pull-Request: #4037.
This commit is contained in:
Thomas Eizinger
2023-06-08 03:38:18 +02:00
committed by GitHub
parent d2dab94b76
commit ed14630672
41 changed files with 172 additions and 348 deletions

View File

@ -446,7 +446,7 @@ pub enum Event {
fn multiaddr_matches_peer_id(addr: &Multiaddr, peer_id: &PeerId) -> bool {
let last_component = addr.iter().last();
if let Some(multiaddr::Protocol::P2p(multi_addr_peer_id)) = last_component {
return multi_addr_peer_id == *peer_id.as_ref();
return multi_addr_peer_id == *peer_id;
}
true
}
@ -504,8 +504,8 @@ mod tests {
let addr_without_peer_id: Multiaddr = addr.clone();
let mut addr_with_other_peer_id = addr.clone();
addr.push(multiaddr::Protocol::P2p(peer_id.into()));
addr_with_other_peer_id.push(multiaddr::Protocol::P2p(other_peer_id.into()));
addr.push(multiaddr::Protocol::P2p(peer_id));
addr_with_other_peer_id.push(multiaddr::Protocol::P2p(other_peer_id));
assert!(multiaddr_matches_peer_id(&addr, &peer_id));
assert!(!multiaddr_matches_peer_id(