diff --git a/chain-signatures/node/src/http_client.rs b/chain-signatures/node/src/http_client.rs index eaf5c37c..4620a805 100644 --- a/chain-signatures/node/src/http_client.rs +++ b/chain-signatures/node/src/http_client.rs @@ -44,7 +44,7 @@ pub enum SendError { ParticipantNotAlive(String), } -async fn send_encrypted( +pub async fn send_encrypted( from: Participant, client: &Client, url: U, diff --git a/chain-signatures/node/src/mesh/connection.rs b/chain-signatures/node/src/mesh/connection.rs index 18041fe1..310f4363 100644 --- a/chain-signatures/node/src/mesh/connection.rs +++ b/chain-signatures/node/src/mesh/connection.rs @@ -9,6 +9,7 @@ use crate::protocol::contract::primitives::Participants; use crate::protocol::ParticipantInfo; use crate::protocol::ProtocolState; use crate::web::StateView; +use mpc_keys::hpke::Ciphered; // TODO: this is a basic connection pool and does not do most of the work yet. This is // mostly here just to facilitate offline node handling for now. @@ -71,10 +72,15 @@ impl Pool { let mut participants = Participants::default(); for (participant, info) in connections.iter() { match self.fetch_participant_state(info).await { - Ok(state) => { - status.insert(*participant, state); - participants.insert(participant, info.clone()); - } + Ok(state) => match self.send_empty_msg(participant, info).await { + Ok(()) => { + status.insert(*participant, state); + participants.insert(participant, info.clone()); + } + Err(e) => { + tracing::warn!("Send empty msg for participant {participant:?} with url {} has failed with error {e}.", info.url); + } + }, Err(e) => { tracing::warn!("Fetch state for participant {participant:?} with url {} has failed with error {e}.", info.url); } @@ -100,10 +106,15 @@ impl Pool { let mut participants = Participants::default(); for (participant, info) in connections.iter() { match self.fetch_participant_state(info).await { - Ok(state) => { - status.insert(*participant, state); - participants.insert(participant, info.clone()); - } + Ok(state) => match self.send_empty_msg(participant, info).await { + Ok(()) => { + status.insert(*participant, state); + participants.insert(participant, info.clone()); + } + Err(e) => { + tracing::warn!("Send empty msg for participant {participant:?} with url {} has failed with error {e}.", info.url); + } + }, Err(e) => { tracing::warn!("Fetch state for participant {participant:?} with url {} has failed with error {e}.", info.url); } @@ -186,4 +197,20 @@ impl Pool { Err(_) => Err(FetchParticipantError::Timeout), } } + + async fn send_empty_msg( + &self, + participant: &Participant, + participant_info: &ParticipantInfo, + ) -> Result<(), crate::http_client::SendError> { + let empty_msg: Vec = Vec::new(); + crate::http_client::send_encrypted( + *participant, + &self.http, + participant_info.url.clone(), + empty_msg, + self.fetch_participant_timeout, + ) + .await + } }