Skip to content

Commit 09029c9

Browse files
committed
refactor: use getter methods
1 parent ca2a659 commit 09029c9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/branch_and_bound.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
172172

173173
// descending sort by effective_value, ascending sort by waste.
174174
weighted_utxos
175-
.sort_by(|a, b| b.effective_value().cmp(&a.effective_value()).then(a.waste.cmp(&b.waste)));
175+
.sort_by(|a, b| b.effective_value().cmp(&a.effective_value()).then(a.waste().cmp(&b.waste())));
176176

177177
if available_value < target {
178178
return Err(InsufficentFunds);
@@ -247,13 +247,13 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
247247
break;
248248
}
249249

250-
let eff_value = weighted_utxos[index].effective_value;
250+
let eff_value = weighted_utxos[index].effective_value_raw();
251251
available_value += eff_value;
252252
}
253253

254254
assert_eq!(index, *index_selection.last().unwrap());
255-
let eff_value = weighted_utxos[index].effective_value;
256-
let utxo_waste = weighted_utxos[index].waste;
255+
let eff_value = weighted_utxos[index].effective_value_raw();
256+
let utxo_waste = weighted_utxos[index].waste_raw();
257257
let utxo_weight = weighted_utxos[index].weight();
258258
current_waste = current_waste.checked_sub(utxo_waste).ok_or(Overflow(Subtraction))?;
259259
value = value.checked_sub(eff_value).ok_or(Overflow(Addition))?;
@@ -262,9 +262,9 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
262262
}
263263
// * Add next node to the inclusion branch.
264264
else {
265-
let eff_value = weighted_utxos[index].effective_value;
265+
let eff_value = weighted_utxos[index].effective_value_raw();
266266
let utxo_weight = weighted_utxos[index].weight();
267-
let utxo_waste = weighted_utxos[index].waste;
267+
let utxo_waste = weighted_utxos[index].waste_raw();
268268

269269
// unchecked sub is used her for performance.
270270
// The bounds for available_value are at most the sum of utxos
@@ -277,7 +277,7 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
277277
// Check if the previous UTXO was included.
278278
|| index - 1 == *index_selection.last().unwrap()
279279
// Check if the previous UTXO has the same value has the previous one.
280-
|| weighted_utxos[index].effective_value != weighted_utxos[index - 1].effective_value
280+
|| weighted_utxos[index].effective_value_raw() != weighted_utxos[index - 1].effective_value_raw()
281281
{
282282
index_selection.push(index);
283283
current_waste = current_waste.checked_add(utxo_waste).ok_or(Overflow(Addition))?;

0 commit comments

Comments
 (0)