Skip to content

Commit

Permalink
Fix echo broadcast svc to handle init msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
pool2win committed Nov 20, 2024
1 parent 1b8c62e commit 4f7afb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/node/echo_broadcast/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ where
}
}

fn call(&mut self, msg: Message) -> Self::Future {
/// Handles the message by sending echo if required
/// If it is a broadcast message with None in message, we always drop that message and a new one is generated by inner service
fn call(&mut self, mut msg: Message) -> Self::Future {
let mut this = self.clone();
Box::pin(async move {
let members = this.state.membership_handle.get_members().await.unwrap();
Expand All @@ -87,14 +89,10 @@ where
.await?;
log::info!("Deliver ECHO ...");
}
// mid is not available in Broadcast - implies we are sending this broadcast
Message::Broadcast(m, None) => {
log::debug!("Generating message_id for Send...");
let to_send =
Message::Broadcast(m, Some(this.state.message_id_generator.next()));
this.handle.send(to_send, members.clone()).await?;
}
// mid is not available in Broadcast - we do nothing here, message_id will be generated by inner service
Message::Broadcast(_, None) => {}
};
// call inner service to generate response. This will generate a new message if it is an initial message with None in message field.
let response_message = this.inner.call(msg).await;
match response_message {
Ok(Some(msg)) => {
Expand Down
2 changes: 2 additions & 0 deletions src/node/protocol/dkg/round_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ async fn build_round1_package(
);
match result {
Ok((secret_package, round1_package)) => {
log::debug!("Setting round one package as {:?}", round1_package);
let _ = state
.dkg_state
.add_round1_secret_package(secret_package)
Expand Down Expand Up @@ -128,6 +129,7 @@ impl Service<Message> for Package {
) => {
log::debug!("Build round one package");
let response = build_round1_package(this_sender_id, state).await?;
log::debug!("Sending round one package {:?}", response);
Ok(Some(response))
}
Message::Broadcast(
Expand Down

0 comments on commit 4f7afb4

Please sign in to comment.