From 73f9a350331f6c6269f7f60e1e94612c948fb423 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 26 Jan 2026 14:40:32 +0000 Subject: [PATCH] protocol: reuse session address for reconnect When maintaining persistent connections, the config was consulted for a peer address. Multiple addresses for a single `NodeId` can be listed. This can result in a different address being used for reconnecting if the `HashSet` returns in a different order. The original address that was used for connection is in the `Session`, so this should be used instead. --- crates/radicle-protocol/src/service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/radicle-protocol/src/service.rs b/crates/radicle-protocol/src/service.rs index ad3f9d0c..d4ef6fa8 100644 --- a/crates/radicle-protocol/src/service.rs +++ b/crates/radicle-protocol/src/service.rs @@ -2671,13 +2671,13 @@ where let mut reconnect = Vec::new(); for (nid, session) in self.sessions.iter_mut() { - if let Some(addr) = self.config.peer(nid) { + if self.config.is_persistent(nid) { if let session::State::Disconnected { retry_at, .. } = &mut session.state { // TODO: Try to reconnect only if the peer was attempted. A disconnect without // even a successful attempt means that we're unlikely to be able to reconnect. if now >= *retry_at { - reconnect.push((*nid, addr.clone(), session.attempts())); + reconnect.push((*nid, session.addr.clone(), session.attempts())); } } }