Skip to content

Commit

Permalink
Merge pull request #116 from crisdut/fix/bundle-merge-check
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky authored Dec 27, 2023
2 parents 34079cb + d53454a commit e028cd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/accessors/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl BundleExt for TransitionBundle {
return Ok(false);
}
self.known_transitions
.insert(opid, transition.clone())
.insert(opid, transition)
.expect("same size as input map");
Ok(true)
}
Expand Down
16 changes: 9 additions & 7 deletions src/accessors/merge_reveal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub enum MergeRevealError {
#[display(inner)]
AnchorMismatch(MergeError),

/// the merged bundles contain excessive transactions.
ExcessiveTransactions,
/// the merged bundles contain excessive transitions.
ExcessiveTransitions,

/// contract id provided for the merge-reveal operation doesn't matches
/// multi-protocol commitment.
Expand Down Expand Up @@ -187,12 +187,14 @@ impl<Seal: ExposedSeal> MergeReveal for Assignments<Seal> {
impl MergeReveal for TransitionBundle {
fn merge_reveal(mut self, other: Self) -> Result<Self, MergeRevealError> {
debug_assert_eq!(self.commitment_id(), other.commitment_id());
if self.known_transitions.len() + other.known_transitions.len() > self.input_map.len() ||
self.known_transitions
.extend(other.known_transitions)
.is_err()

if self
.known_transitions
.extend(other.known_transitions)
.is_err() ||
self.input_map.len() < self.known_transitions.len()
{
return Err(MergeRevealError::ExcessiveTransactions);
return Err(MergeRevealError::ExcessiveTransitions);
}
Ok(self)
}
Expand Down
2 changes: 1 addition & 1 deletion src/persistence/hoard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl Hoard {

// Update asset tags
self.asset_tags
.insert(contract_id, consignment.asset_tags.clone())?;
.insert(contract_id, consignment.asset_tags)?;

Ok(())
}
Expand Down

0 comments on commit e028cd6

Please sign in to comment.