Skip to content

Commit 4d7e500

Browse files
committed
refactor: use getter methods
1 parent ca2a659 commit 4d7e500

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/branch_and_bound.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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))?;

src/coin_grinder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ mod tests {
672672
let w = u.int_in_range::<u64>(1..=Weight::MAX.to_wu()).unwrap();
673673
let wu = Weight::from_wu(w);
674674
WeightedUtxo::new(
675-
utxo.value,
675+
utxo.value(),
676676
wu,
677677
exclusion_set.fee_rate,
678678
exclusion_set.long_term_fee_rate,
@@ -685,14 +685,14 @@ mod tests {
685685
.iter()
686686
.map(|utxo| {
687687
WeightedUtxo::new(
688-
utxo.value,
688+
utxo.value(),
689689
Weight::ZERO,
690690
inclusion_set.fee_rate,
691691
inclusion_set.long_term_fee_rate,
692692
)
693693
.unwrap()
694694
})
695-
.filter(|utxo| utxo.value == Amount::ZERO)
695+
.filter(|utxo| utxo.value() == Amount::ZERO)
696696
.collect();
697697

698698
if let Some(target) = weightless_pool.iter().map(|utxo| utxo.value()).checked_sum() {

0 commit comments

Comments
 (0)