Skip to content

Commit

Permalink
improve DKGNodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
kafeikui committed May 23, 2024
1 parent 6e9b366 commit ca97de0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
15 changes: 9 additions & 6 deletions crates/arpa-node/src/algorithm/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ where
}
}
Err(err) => match err {
DKGNodeError::NotEnoughValidShares(_, _, disqualified_node_indices) => {
Ok(DKGOutput::<C>::fail(disqualified_node_indices))
}
DKGNodeError::NotEnoughJustifications(_, _, disqualified_node_indices) => {
Ok(DKGOutput::<C>::fail(disqualified_node_indices))
}
DKGNodeError::DKGError(e) => match e {
DKGError::NotEnoughValidShares(_, _, disqualified_node_indices) => {
Ok(DKGOutput::<C>::fail(disqualified_node_indices))
}
DKGError::NotEnoughJustifications(_, _, disqualified_node_indices) => {
Ok(DKGOutput::<C>::fail(disqualified_node_indices))
}
_ => Err(e.into()),
},
_ => Err(err.into()),
},
}
Expand Down
13 changes: 1 addition & 12 deletions crates/dkg-core/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ pub enum DKGNodeError {
/// There was an internal error in the DKG
#[error("DKG Error: {0}")]
DKGError(#[from] DKGError),

#[error("only has {0}/{1} valid shares, disqualified: {2:?}")]
NotEnoughValidShares(usize, usize, Vec<u32>),

#[error("only has {0}/{1} required justifications, disqualified: {2:?}")]
NotEnoughJustifications(usize, usize, Vec<u32>),
}

/// Phase2 can either be successful or require going to Phase 3.
Expand Down Expand Up @@ -115,12 +109,7 @@ where

Ok(next)
}
Err(e) => match e {
DKGError::NotEnoughValidShares(got, required, disqualified_node_indices) => Err(
DKGNodeError::NotEnoughValidShares(got, required, disqualified_node_indices),
),
_ => Err(DKGNodeError::DKGError(e)),
},
Err(e) => Err(DKGNodeError::DKGError(e)),
}
}
}
Expand Down

0 comments on commit ca97de0

Please sign in to comment.