Skip to content

Commit fac6e32

Browse files
committed
Fix infimum and supremum operations.
1 parent 83f5340 commit fac6e32

File tree

1 file changed

+4
-10
lines changed
  • masp_primitives/src/transaction/components

1 file changed

+4
-10
lines changed

masp_primitives/src/transaction/components/amount.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,10 @@ where
9797
pub fn inf(&self, rhs: &Self) -> Self {
9898
let mut comps = BTreeMap::new();
9999
for (atype, rhs_amount) in rhs.components() {
100-
// rhs_amount is positive by definition
101100
let lhs_amount = self.get(atype);
102-
if lhs_amount.is_zero() {
103-
continue;
104-
} else if lhs_amount <= *rhs_amount {
105-
// lhs_amount is positive since first branch was skipped
101+
if lhs_amount <= *rhs_amount && !lhs_amount.is_zero() {
106102
comps.insert(atype.clone(), lhs_amount);
107-
} else {
103+
} else if lhs_amount > *rhs_amount && !rhs_amount.is_zero() {
108104
comps.insert(atype.clone(), *rhs_amount);
109105
}
110106
}
@@ -115,12 +111,10 @@ where
115111
pub fn sup(&self, rhs: &Self) -> Self {
116112
let mut comps = BTreeMap::new();
117113
for (atype, rhs_amount) in rhs.components() {
118-
// rhs_amount is positive by definition
119114
let lhs_amount = self.get(atype);
120-
if lhs_amount <= *rhs_amount {
115+
if lhs_amount <= *rhs_amount && !rhs_amount.is_zero() {
121116
comps.insert(atype.clone(), *rhs_amount);
122-
} else {
123-
// lhs_amount is positive since it's more than rhs_amount
117+
} else if lhs_amount > *rhs_amount && !lhs_amount.is_zero() {
124118
comps.insert(atype.clone(), lhs_amount);
125119
}
126120
}

0 commit comments

Comments
 (0)