Skip to content

Commit

Permalink
chore: cleanup linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Nov 26, 2024
1 parent 4c04113 commit 68b3d0f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions packages/libp2p-relay-manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-relay-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
51 changes: 21 additions & 30 deletions packages/libp2p-relay-manager/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
| _ => {}
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,9 @@ impl Stream for RepoGetBlocks {
let _guard = repo.gc_guard().await;
let mut missing: IndexSet<Cid> = 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);
}
}

Expand Down

0 comments on commit 68b3d0f

Please sign in to comment.