From eb5b9ecc4bf2ee41ac1c74968368fff9e928f1d1 Mon Sep 17 00:00:00 2001 From: Till Rohrmann Date: Wed, 27 Nov 2024 17:33:34 +0100 Subject: [PATCH] Return error when connecting to remote metadata store peer --- crates/metadata-store/src/network/networking.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/metadata-store/src/network/networking.rs b/crates/metadata-store/src/network/networking.rs index d12636eb5..e361d9195 100644 --- a/crates/metadata-store/src/network/networking.rs +++ b/crates/metadata-store/src/network/networking.rs @@ -31,6 +31,8 @@ use tracing::{debug, trace}; pub enum TrySendError { #[error("failed sending message")] Send(T), + #[error("connecting to peer")] + Connecting(T), #[error("unknown peer: {0}")] UnknownPeer(u64), #[error(transparent)] @@ -81,7 +83,7 @@ impl Networking { } else if let Some(address) = self.addresses.get(&target) { if let Some(task_handle) = self.connection_attempts.remove(&target) { if !task_handle.is_finished() { - return Ok(()); + return Err(TrySendError::Connecting(message)); } else { match task_handle.now_or_never().expect("should be finished") { Ok(result) => { @@ -107,6 +109,7 @@ impl Networking { &Configuration::pinned().networking, )?, ); + return Err(TrySendError::Connecting(message)); } else { return Err(TrySendError::UnknownPeer(target)); }