Skip to content

Commit 5636c1e

Browse files
committed
fix: Await async_channel::Sender::send
This makes sure to await the future from async_channel::Sender::send. When not awaiting this only makes a struct and noting is ever sent. Caught by clippy really.
1 parent 7a11aa8 commit 5636c1e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

iroh-bitswap/src/client/peer_manager.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{fmt::Debug, sync::Arc};
22

33
use ahash::{AHashMap, AHashSet};
4-
use anyhow::Result;
4+
use anyhow::{Context, Result};
55
use cid::Cid;
66
use derivative::Derivative;
77
use futures::{future::BoxFuture, FutureExt};
@@ -658,10 +658,15 @@ impl PeerManagerActor {
658658
) {
659659
if let Some(session) = self.sessions.get(&session) {
660660
if session.peers.contains(&peer) {
661-
self.network.protect_peer(peer).await;
661+
self.network
662+
.protect_peer(peer)
663+
.await
664+
.context("Failed to protect connection")
665+
.map_err(|err| error!("{err:#}"))
666+
.ok();
662667
}
663668
}
664-
let _ = response.send(());
669+
response.send(()).ok();
665670
}
666671

667672
async fn remove_peer_from_session(

iroh-bitswap/src/network.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,22 @@ impl Network {
297297
trace!("untag {}: {}", peer, tag);
298298
}
299299

300-
pub async fn protect_peer(&self, peer: PeerId) {
300+
pub async fn protect_peer(&self, peer: PeerId) -> Result<()> {
301301
trace!("protect {}", peer);
302-
let _ = self.network_out_sender.send(OutEvent::ProtectPeer { peer });
302+
self.network_out_sender
303+
.send(OutEvent::ProtectPeer { peer })
304+
.await?;
305+
Ok(())
303306
}
304307

305308
pub async fn unprotect_peer(&self, peer: PeerId) -> bool {
306309
trace!("unprotect {}", peer);
307310

308311
let (s, r) = oneshot::channel();
309-
let _ = self
310-
.network_out_sender
311-
.send(OutEvent::UnprotectPeer { peer, response: s });
312+
self.network_out_sender
313+
.send(OutEvent::UnprotectPeer { peer, response: s })
314+
.await
315+
.ok();
312316

313317
r.await.unwrap_or_default()
314318
}

0 commit comments

Comments
 (0)