Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeoghegan committed Sep 11, 2023
1 parent f87306f commit 5f9658f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/topology/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0

//! Implementations of the aggregator communication topologies specified in [VDAF].
//! Implementations of some aggregator communication topologies specified in [VDAF].
//!
//! [VDAF]: https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vdaf-06#section-5.7
Expand Down
27 changes: 15 additions & 12 deletions src/topology/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ pub enum PingPongError {
},

/// Message from peer indicates it is in an unexpected state
#[error("peer message state mismatch: message is {found} expected {expected}")]
PeerMessageStateMismatch {
#[error("peer message mismatch: message is {found} expected {expected}")]
PeerMessageMismatch {
/// The state in the message from the peer.
found: &'static str,
/// The state the message from the peer was expected to be in.
/// The message expected from the peer.
expected: &'static str,
},

Expand Down Expand Up @@ -549,7 +549,7 @@ where
Self::PrepareShare::get_decoded_with_param(&prep_state, prep_share)
.map_err(PingPongError::CodecPrepShare)?
} else {
return Err(PingPongError::PeerMessageStateMismatch {
return Err(PingPongError::PeerMessageMismatch {
found: inbound.variant(),
expected: "initialize",
});
Expand Down Expand Up @@ -604,7 +604,7 @@ where

let (prep_msg, next_peer_prep_share) = match inbound {
PingPongMessage::Initialize { .. } => {
return Err(PingPongError::PeerMessageStateMismatch {
return Err(PingPongError::PeerMessageMismatch {
found: inbound.variant(),
expected: "continued",
});
Expand Down Expand Up @@ -650,13 +650,16 @@ where
(PrepareTransition::Finish(output_share), None) => {
Ok(PingPongContinuedValue::FinishedNoMessage { output_share })
}
(transition, _) => {
return Err(PingPongError::HostStateMismatch {
found: match transition {
PrepareTransition::Continue(_, _) => "continue",
PrepareTransition::Finish(_) => "finished",
},
expected: inbound.variant(),
(PrepareTransition::Continue(_, _), None) => {
return Err(PingPongError::PeerMessageMismatch {
found: inbound.variant(),
expected: "continue",
})
}
(PrepareTransition::Finish(_), Some(_)) => {
return Err(PingPongError::PeerMessageMismatch {
found: inbound.variant(),
expected: "finish",
})
}
}
Expand Down

0 comments on commit 5f9658f

Please sign in to comment.