Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwoodbury committed Nov 9, 2023
1 parent e3368cf commit 96469af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async fn run(
let peer_str = peer_id.to_string();
if peer_str < own_id_str {
log::debug!("dialing peer");
if let Err(e) = webrtc_controller.dial(&peer_id).await {
if let Err(e) = webrtc_controller.dial(peer_id).await {
log::error!("failed to dial peer: {e}");
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/warp-blink-wrtc/src/blink_impl/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ impl CallDataMap {
}

pub fn get_active_mut(&mut self) -> Option<&mut CallData> {
match self.active_call.clone() {
match self.active_call {
None => None,
Some(call_id) => self.map.get_mut(&call_id),
}
}

pub fn get_active(&self) -> Option<&CallData> {
match self.active_call.clone() {
match self.active_call {
None => None,
Some(call_id) => self.map.get(&call_id),
}
Expand Down
48 changes: 20 additions & 28 deletions extensions/warp-blink-wrtc/src/blink_impl/gossipsub_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,41 +218,33 @@ async fn run(
_ = retry_timer.tick() => {
for (_dest, queue) in ecdh_queue.iter_mut() {
while let Some(cmd) = queue.pop_front() {
match cmd {
GossipSubCmd::SendEcdh { dest, signal, topic } => {
let encrypted = match ecdh_encrypt(&own_id, &dest, signal.clone()) {
Ok(r) => r,
Err(e) => {
log::error!("failed to encrypt ecdh message: {e}");
continue;
}
};
if ipfs.pubsub_publish(topic.clone(), encrypted).await.is_err() {
queue.push_front(GossipSubCmd::SendEcdh { dest, signal, topic });
break;
if let GossipSubCmd::SendEcdh { dest, signal, topic } = cmd {
let encrypted = match ecdh_encrypt(&own_id, &dest, signal.clone()) {
Ok(r) => r,
Err(e) => {
log::error!("failed to encrypt ecdh message: {e}");
continue;
}
};
if ipfs.pubsub_publish(topic.clone(), encrypted).await.is_err() {
queue.push_front(GossipSubCmd::SendEcdh { dest, signal, topic });
break;
}
_ => {}
}
}
}
}
_ = announce_timer.tick() => {
if let Some(cmd) = to_announce.as_ref() {
match cmd {
GossipSubCmd::Announce { group_key, signal, topic } => {
let encrypted = match Cipher::direct_encrypt(&signal, &group_key) {
Ok(r) => r,
Err(e) => {
log::error!("failed to encrypt aes message: {e}");
continue;
}
};
if let Err(e) = ipfs.pubsub_publish(topic.clone(), encrypted).await {
log::error!("failed to publish aes message: {e}");
}
if let Some(GossipSubCmd::Announce { group_key, signal, topic }) = to_announce.as_ref() {
let encrypted = match Cipher::direct_encrypt(signal, group_key) {
Ok(r) => r,
Err(e) => {
log::error!("failed to encrypt aes message: {e}");
continue;
}
_ => {}
};
if let Err(e) = ipfs.pubsub_publish(topic.clone(), encrypted).await {
log::error!("failed to publish aes message: {e}");
}
}
}
Expand Down Expand Up @@ -288,7 +280,7 @@ async fn run(
}
};
if ipfs.pubsub_publish(topic.clone(), encrypted).await.is_err() {
let queue = ecdh_queue.entry(dest.clone()).or_insert(VecDeque::new());
let queue = ecdh_queue.entry(dest.clone()).or_default();
queue.push_back(GossipSubCmd::SendEcdh { dest, signal, topic });
}
}
Expand Down

0 comments on commit 96469af

Please sign in to comment.