Skip to content

Commit

Permalink
feat: added not any_of and all_of filters
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobressan committed Aug 29, 2023
1 parent cb88b44 commit 8df5c10
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/filters/match_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ pub enum Predicate {
OutputAddress(AddressPattern),
WithdrawalAddress(AddressPattern),
CollateralAddress(AddressPattern),
Not(Box<Predicate>),
AnyOf(Vec<Predicate>),
AllOf(Vec<Predicate>),
}

impl Predicate {
Expand All @@ -141,6 +144,23 @@ impl Predicate {
Predicate::CollateralAddress(address_pattern) => {
Ok(collateral_match(tx, address_pattern)?)
}
Predicate::Not(x) => Ok(!x.tx_match(point, tx)?),
Predicate::AnyOf(x) => {
for p in x {
if p.tx_match(point, tx)? {
return Ok(true);
};
}
Ok(false)
}
Predicate::AllOf(x) => {
for p in x {
if !p.tx_match(point, tx)? {
return Ok(false);
};
}
Ok(true)
}
}
}
}
Expand Down

0 comments on commit 8df5c10

Please sign in to comment.