From 3a68fdb79fc81db0105043781c73d7bd169f7da0 Mon Sep 17 00:00:00 2001 From: Ignacio Duart Date: Tue, 11 Jun 2024 18:03:16 +0200 Subject: [PATCH] Don't crash if there are no peers anymore --- crates/core/src/ring.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/core/src/ring.rs b/crates/core/src/ring.rs index e860e98a2..4e36911ed 100644 --- a/crates/core/src/ring.rs +++ b/crates/core/src/ring.rs @@ -615,7 +615,9 @@ impl Ring { ) -> Option { 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;