diff --git a/Cargo.lock b/Cargo.lock index 0214d0cde..a200ba99b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2883,7 +2883,7 @@ dependencies = [ [[package]] name = "libp2p-relay-manager" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8a51e1ab1..6a8e7dca7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ ipld-dagpb = "0.2.1" libp2p = { version = "0.54.1" } libp2p-allow-block-list = "0.4.0" libp2p-connection-limits = "0.4.0" -libp2p-relay-manager = { version = "0.3.0", path = "packages/libp2p-relay-manager" } +libp2p-relay-manager = { version = "0.3.1", path = "packages/libp2p-relay-manager" } libp2p-stream = { version = "0.2.0-alpha" } libp2p-webrtc = { version = "=0.8.0-alpha", features = ["pem"] } libp2p-webrtc-websys = "0.4.0-alpha" diff --git a/packages/libp2p-relay-manager/CHANGELOG.md b/packages/libp2p-relay-manager/CHANGELOG.md index 22970e2b5..ce07fa3f2 100644 --- a/packages/libp2p-relay-manager/CHANGELOG.md +++ b/packages/libp2p-relay-manager/CHANGELOG.md @@ -1,3 +1,5 @@ +# 0.3.1 + # 0.3.0 - chore: Update libp2p to 0.54. [PR 289](https://github.com/dariusc93/rust-ipfs/pull/289) diff --git a/packages/libp2p-relay-manager/Cargo.toml b/packages/libp2p-relay-manager/Cargo.toml index 5ca87ba4a..6256746f3 100644 --- a/packages/libp2p-relay-manager/Cargo.toml +++ b/packages/libp2p-relay-manager/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-relay-manager" -version = "0.3.0" +version = "0.3.1" edition = "2021" license = "Apache-2.0 OR MIT" description = "(WIP) Implementation of a relay-manager" diff --git a/packages/libp2p-relay-manager/src/handler.rs b/packages/libp2p-relay-manager/src/handler.rs index e3a6f3bae..4fd8e00a7 100644 --- a/packages/libp2p-relay-manager/src/handler.rs +++ b/packages/libp2p-relay-manager/src/handler.rs @@ -66,40 +66,31 @@ impl ConnectionHandler for Handler { Self::OutboundOpenInfo, >, ) { - match event { - ConnectionEvent::RemoteProtocolsChange(protocol) => { - let change = self.supported_protocol.on_protocols_change(protocol); - if change { - let valid = self - .supported_protocol - .iter() - .any(|proto| libp2p::relay::HOP_PROTOCOL_NAME.eq(proto)); + if let ConnectionEvent::RemoteProtocolsChange(protocol) = event { + let change = self.supported_protocol.on_protocols_change(protocol); + if change { + let valid = self + .supported_protocol + .iter() + .any(|proto| libp2p::relay::HOP_PROTOCOL_NAME.eq(proto)); - match (valid, self.supported) { - (true, false) => { - self.supported = true; - self.events - .push_back(ConnectionHandlerEvent::NotifyBehaviour(Out::Supported)); - } - (false, true) => { - self.supported = false; - self.events - .push_back(ConnectionHandlerEvent::NotifyBehaviour( - Out::Unsupported, - )); - } - (true, true) => {} - _ => {} + match (valid, self.supported) { + (true, false) => { + self.supported = true; + self.events + .push_back(ConnectionHandlerEvent::NotifyBehaviour(Out::Supported)); } + (false, true) => { + self.supported = false; + self.events + .push_back(ConnectionHandlerEvent::NotifyBehaviour( + Out::Unsupported, + )); + } + (true, true) => {} + _ => {} } } - ConnectionEvent::FullyNegotiatedInbound(_) - | ConnectionEvent::FullyNegotiatedOutbound(_) - | ConnectionEvent::AddressChange(_) - | ConnectionEvent::DialUpgradeError(_) - | ConnectionEvent::ListenUpgradeError(_) - | ConnectionEvent::LocalProtocolsChange(_) - | _ => {} } } diff --git a/src/repo/mod.rs b/src/repo/mod.rs index 0fb4279e7..a22dc9acc 100644 --- a/src/repo/mod.rs +++ b/src/repo/mod.rs @@ -1012,12 +1012,9 @@ impl Stream for RepoGetBlocks { let _guard = repo.gc_guard().await; let mut missing: IndexSet = cids.clone(); for cid in &cids { - match repo.get_block_now(cid).await { - Ok(Some(block)) => { - yield Ok(block); - missing.shift_remove(cid); - } - Ok(None) | Err(_) => {} + if let Ok(Some(block)) = repo.get_block_now(cid).await { + yield Ok(block); + missing.shift_remove(cid); } }