Skip to content

Commit

Permalink
Don't crash if there are no peers anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
iduartgomez committed Jun 11, 2024
1 parent 6066aca commit 3a68fdb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/core/src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ impl Ring {
) -> Option<PeerKeyLocation> {
let connections = self.connections_by_location.read();
let peers = connections.values().filter_map(|conns| {
let conn = conns.choose(&mut rand::thread_rng()).unwrap();
let Some(conn) = conns.choose(&mut rand::thread_rng()) else {
return None;
};
if let Some(requester) = requesting {
if requester == &conn.location.peer {
return None;
Expand Down

0 comments on commit 3a68fdb

Please sign in to comment.