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 { impl CommitMessage {
/// Create a new commitment message for a creation/update transaction /// Create a new commitment message for a creation/update transaction
/// validation_tokens must be empty pub fn new(
pub fn new_update_commitment(
process_id: OutPoint, process_id: OutPoint,
pcd_commitment: PcdCommitments, pcd_commitment: PcdCommitments,
roles: Roles, roles: Roles,
public_data: Pcd, public_data: Pcd,
validation_tokens: Vec<Proof>
) -> Self { ) -> Self {
Self { Self {
process_id, process_id,
pcd_commitment, pcd_commitment,
roles, roles,
public_data, public_data,
validation_tokens: vec![], validation_tokens,
error: None, error: None,
} }
} }
/// Set the validation tokens for a pending commitment /// Add validation tokens for a pending commitment
pub fn set_validation_tokens(&mut self, validation_tokens: Vec<Proof>) { pub fn add_validation_tokens(&mut self, validation_tokens: Vec<Proof>) {
self.validation_tokens = validation_tokens; 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![];
} }
} }