diff --git a/goas/cl/cl/src/balance.rs b/goas/cl/cl/src/balance.rs index 4a49ea5..765eb7c 100644 --- a/goas/cl/cl/src/balance.rs +++ b/goas/cl/cl/src/balance.rs @@ -67,41 +67,34 @@ impl BalanceWitness { } pub fn insert_positive(&mut self, unit: Unit, value: Value) { - let mut found = false; for unit_bal in self.balances.iter_mut() { if unit_bal.unit == unit { - found = true; unit_bal.pos += value; - break; + return; } } - if !found { - self.balances.push(UnitBalance { - unit, - pos: value, - neg: 0, - }); - } + // Unit was not found, so we must create one. + self.balances.push(UnitBalance { + unit, + pos: value, + neg: 0, + }); } pub fn insert_negative(&mut self, unit: Unit, value: Value) { - let mut found = false; for unit_bal in self.balances.iter_mut() { if unit_bal.unit == unit { - found = true; unit_bal.neg += value; - break; + return; } } - if !found { - self.balances.push(UnitBalance { - unit, - pos: 0, - neg: value, - }); - } + self.balances.push(UnitBalance { + unit, + pos: 0, + neg: value, + }); } pub fn clear_zeros(&mut self) { diff --git a/goas/cl/cl/tests/simple_transfer.rs b/goas/cl/cl/tests/simple_transfer.rs index 8c20302..9bc68e5 100644 --- a/goas/cl/cl/tests/simple_transfer.rs +++ b/goas/cl/cl/tests/simple_transfer.rs @@ -36,7 +36,6 @@ fn test_simple_transfer() { let bundle = cl::BundleWitness { partials: vec![ptx_witness], - balance_blinding: BalanceWitness::random_blinding(&mut rng), }; assert!(bundle.balance().is_zero())