From 5f9658f98dee3a8dfc9b6ebd338fa60a4ef3b0c4 Mon Sep 17 00:00:00 2001 From: Tim Geoghegan Date: Fri, 1 Sep 2023 11:24:48 -0700 Subject: [PATCH] review feedback --- src/topology/mod.rs | 2 +- src/topology/ping_pong.rs | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/topology/mod.rs b/src/topology/mod.rs index 8bf73d45f..fdce6d722 100644 --- a/src/topology/mod.rs +++ b/src/topology/mod.rs @@ -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 diff --git a/src/topology/ping_pong.rs b/src/topology/ping_pong.rs index 2c490e6b7..459b153d5 100644 --- a/src/topology/ping_pong.rs +++ b/src/topology/ping_pong.rs @@ -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, }, @@ -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", }); @@ -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", }); @@ -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", }) } }