@@ -171,8 +171,9 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
171171 let mut weighted_utxos: Vec < _ > = weighted_utxos. into_iter ( ) . collect ( ) ;
172172
173173 // descending sort by effective_value, ascending sort by waste.
174- weighted_utxos
175- . sort_by ( |a, b| b. effective_value ( ) . cmp ( & a. effective_value ( ) ) . then ( a. waste . cmp ( & b. waste ) ) ) ;
174+ weighted_utxos. sort_by ( |a, b| {
175+ b. effective_value ( ) . cmp ( & a. effective_value ( ) ) . then ( a. waste ( ) . cmp ( & b. waste ( ) ) )
176+ } ) ;
176177
177178 if available_value < target {
178179 return Err ( InsufficentFunds ) ;
@@ -247,13 +248,13 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
247248 break ;
248249 }
249250
250- let eff_value = weighted_utxos[ index] . effective_value ;
251+ let eff_value = weighted_utxos[ index] . effective_value_raw ( ) ;
251252 available_value += eff_value;
252253 }
253254
254255 assert_eq ! ( index, * index_selection. last( ) . unwrap( ) ) ;
255- let eff_value = weighted_utxos[ index] . effective_value ;
256- let utxo_waste = weighted_utxos[ index] . waste ;
256+ let eff_value = weighted_utxos[ index] . effective_value_raw ( ) ;
257+ let utxo_waste = weighted_utxos[ index] . waste_raw ( ) ;
257258 let utxo_weight = weighted_utxos[ index] . weight ( ) ;
258259 current_waste = current_waste. checked_sub ( utxo_waste) . ok_or ( Overflow ( Subtraction ) ) ?;
259260 value = value. checked_sub ( eff_value) . ok_or ( Overflow ( Addition ) ) ?;
@@ -262,9 +263,9 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
262263 }
263264 // * Add next node to the inclusion branch.
264265 else {
265- let eff_value = weighted_utxos[ index] . effective_value ;
266+ let eff_value = weighted_utxos[ index] . effective_value_raw ( ) ;
266267 let utxo_weight = weighted_utxos[ index] . weight ( ) ;
267- let utxo_waste = weighted_utxos[ index] . waste ;
268+ let utxo_waste = weighted_utxos[ index] . waste_raw ( ) ;
268269
269270 // unchecked sub is used her for performance.
270271 // The bounds for available_value are at most the sum of utxos
@@ -277,7 +278,7 @@ pub fn branch_and_bound<'a, T: IntoIterator<Item = &'a WeightedUtxo> + std::mark
277278 // Check if the previous UTXO was included.
278279 || index - 1 == * index_selection. last ( ) . unwrap ( )
279280 // 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
281+ || weighted_utxos[ index] . effective_value_raw ( ) != weighted_utxos[ index - 1 ] . effective_value_raw ( )
281282 {
282283 index_selection. push ( index) ;
283284 current_waste = current_waste. checked_add ( utxo_waste) . ok_or ( Overflow ( Addition ) ) ?;
0 commit comments