Skip to content

Commit

Permalink
Fixing errors related to empty contributions on the beginning of the …
Browse files Browse the repository at this point in the history
…round.
  • Loading branch information
ii-cruz committed Mar 26, 2024
1 parent 643d7e0 commit ae9c221
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/bin/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl RoundState {
)
.await;

return Err(MonitorError::ParametersDifferentBetweenRounds(
return Err(MonitorError::MonitorParametersDifferentBetweenRounds(
self.setups_contribution_state.len(),
ceremony.setups.len(),
)
Expand Down Expand Up @@ -188,8 +188,7 @@ impl RoundState {
pending_verification_timeout,
contribution_timeout,
)
.await
.unwrap();
.await?;

if setup_finished.load(Ordering::Relaxed) {
let verified_participant_ids_in_chunk: HashSet<_> = new_chunk
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum MonitorError {
#[error("Lock holder was none")]
LockHolderIsNoneError,
#[error("Parameters were different between rounds: expected. Setups: {0:?}, got {1:?}")]
ParametersDifferentBetweenRounds(usize, usize),
MonitorParametersDifferentBetweenRounds(usize, usize),
}

#[derive(Debug, Error)]
Expand Down
22 changes: 13 additions & 9 deletions src/monitor_setup_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ impl TryFrom<&Contribution> for ChunkState {
type Error = anyhow::Error;

fn try_from(contribution: &Contribution) -> Result<Self> {
Ok(Self::RecordedState {
last_contributor: contribution.contributor_id()?,
metadata: contribution
.metadata
.clone()
.ok_or(VerifyTranscriptError::ContributorDataIsNoneError)?,
verifying_timeout: false,
contributing_timeout: false,
})
if let Result::Ok(contributor_id) = contribution.contributor_id() {
Ok(Self::RecordedState {
last_contributor: contributor_id,
metadata: contribution
.metadata
.clone()
.ok_or(VerifyTranscriptError::ContributorDataIsNoneError)?,
verifying_timeout: false,
contributing_timeout: false,
})
} else {
Ok(Self::EmptyState())
}
}
}

Expand Down

0 comments on commit ae9c221

Please sign in to comment.