net: Remove channels from P2P if broadcast fails.

This commit is contained in:
parazyd
2023-08-12 20:54:31 +02:00
parent 3326e1b060
commit 27735bb6f4

View File

@@ -275,7 +275,10 @@ impl P2p {
}
futures.push(channel.send(message).map_err(|e| {
format!("P2P: Broadcasting message to {} failed: {}", channel.address(), e)
(
format!("[P2P] Broadcasting message to {} failed: {}", channel.address(), e),
channel.clone(),
)
}));
}
@@ -285,10 +288,9 @@ impl P2p {
}
while let Some(entry) = futures.next().await {
// TODO: Here we can close the channels.
// See message_subscriber::_trigger_all on how to do it.
if let Err(e) = entry {
if let Err((e, chan)) = entry {
error!(target: "net::p2p::broadcast()", "{}", e);
self.remove(chan).await;
}
}
}