Skip to content

Commit

Permalink
containers: fix anchor set merge-reveal operation
Browse files Browse the repository at this point in the history
Closes #195
  • Loading branch information
dr-orlovsky committed Apr 18, 2024
1 parent 5084eb2 commit f11cd39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/containers/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,23 @@ impl AnchorSet {
impl AnchorSet {
pub fn merge_reveal(self, other: Self) -> Result<Self, MergeRevealError> {
match (self, other) {
(Self::Tapret(anchor), Self::Tapret(a)) if a == anchor => Ok(Self::Tapret(anchor)),
(Self::Opret(anchor), Self::Opret(a)) if a == anchor => Ok(Self::Opret(anchor)),
(Self::Tapret(anchor), Self::Tapret(a)) if a.matches(&anchor) => {
Ok(Self::Tapret(anchor))
}
(Self::Opret(anchor), Self::Opret(a)) if a.matches(&anchor) => Ok(Self::Opret(anchor)),
(Self::Tapret(tapret), Self::Opret(opret)) |
(Self::Opret(opret), Self::Tapret(tapret)) => Ok(Self::Double { tapret, opret }),

(Self::Double { tapret, opret }, Self::Tapret(t)) |
(Self::Tapret(t), Self::Double { tapret, opret })
if tapret == t =>
if t.matches(&tapret) =>
{
Ok(Self::Double { tapret, opret })
}

(Self::Double { tapret, opret }, Self::Opret(o)) |
(Self::Opret(o), Self::Double { tapret, opret })
if opret == o =>
if o.matches(&opret) =>
{
Ok(Self::Double { tapret, opret })
}
Expand All @@ -289,7 +291,7 @@ impl AnchorSet {
tapret: t,
opret: o,
},
) if tapret == t && opret == o => Ok(Self::Double { tapret, opret }),
) if t.matches(&tapret) && o.matches(&opret) => Ok(Self::Double { tapret, opret }),

_ => Err(MergeRevealError::AnchorsMismatch),
}
Expand Down

0 comments on commit f11cd39

Please sign in to comment.