Lift restriction on new CommitMessage that couldn't take validation tokens

This commit is contained in:
NicolasCantu 2025-03-13 14:38:02 +01:00
parent 7babbc2a74
commit d8f6915a4a

View File

@ -80,26 +80,35 @@ pub struct CommitMessage {
impl CommitMessage {
/// Create a new commitment message for a creation/update transaction
/// validation_tokens must be empty
pub fn new_update_commitment(
pub fn new(
process_id: OutPoint,
pcd_commitment: PcdCommitments,
roles: Roles,
public_data: Pcd,
validation_tokens: Vec<Proof>
) -> Self {
Self {
process_id,
pcd_commitment,
roles,
public_data,
validation_tokens: vec![],
validation_tokens,
error: None,
}
}
/// Set the validation tokens for a pending commitment
pub fn set_validation_tokens(&mut self, validation_tokens: Vec<Proof>) {
self.validation_tokens = validation_tokens;
/// Add validation tokens for a pending commitment
pub fn add_validation_tokens(&mut self, validation_tokens: Vec<Proof>) {
self.validation_tokens.extend_from_slice(&validation_tokens);
self.validation_tokens.sort_unstable();
self.validation_tokens.dedup();
}
/// Remove all validation tokens
/// This should rarely be useful, and we'd rather let caller copy all he needs, sorts on its own
/// and clear here
pub fn clear_validation_tokens(&mut self) {
self.validation_tokens = vec![];
}
}