Replace expect with debug log

This commit is contained in:
Luke Parker 2024-04-21 08:02:13 -04:00
parent b5f2ff1397
commit a3c37cba21
No known key found for this signature in database

View file

@ -541,10 +541,10 @@ impl LibP2p {
}
Some(SwarmEvent::ConnectionClosed { peer_id, endpoint, .. }) => {
let mut connected_peers = connected_peers.write().await;
let nets =
connected_peers
.remove(endpoint.get_remote_address())
.expect("closed connection to peer which never connected");
let Some(nets) = connected_peers.remove(endpoint.get_remote_address()) else {
log::debug!("closed connection to peer which wasn't in connected_peers");
continue;
};
// Downgrade to a read lock
let connected_peers = connected_peers.downgrade();