Some(connection_closed_future) => {
let mut connection_closed_future = Box::pin(connection_closed_future);
loop {
- match futures::poll!(&mut connection_closed_future) {
- std::task::Poll::Ready(_) => {
- return Err(());
- }
- std::task::Poll::Pending => {}
- }
- // Avoid blocking the tokio context by sleeping a bit
- match peer_manager.get_peer_node_ids().iter().find(|(id, _)| *id == pubkey) {
- Some(_) => return Ok(()),
- None => tokio::time::sleep(Duration::from_millis(10)).await,
+ tokio::select! {
+ _ = &mut connection_closed_future => return Err(()),
+ _ = tokio::time::sleep(Duration::from_millis(10)) => {},
+ };
+ if peer_manager.get_peer_node_ids().iter().find(|(id, _)| *id == pubkey).is_some() {
+ return Ok(());
}
}
}