goas: remove found flag from balance insert helpers
This commit is contained in:
parent
7a706583dc
commit
30354a08bd
|
@ -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) {
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue