Skip to content

Commit

Permalink
Add min tail weight
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Nov 16, 2024
1 parent d63ac18 commit 55452c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/coin_grinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub fn coin_grinder<Utxo: WeightedUtxo>(
fee_rate: FeeRate,
weighted_utxos: &[Utxo],
) -> Option<std::vec::IntoIter<&Utxo>> {
println!("start");

// Creates a tuple of (effective_value, weighted_utxo)
let mut w_utxos: Vec<(Amount, &Utxo)> = weighted_utxos
Expand Down Expand Up @@ -87,6 +88,12 @@ pub fn coin_grinder<Utxo: WeightedUtxo>(
Some(*state)
}).collect();

let min_group_weight = w_utxos.clone();
let min_group_weight: Vec<_> = min_group_weight.iter().rev().map(|(e, u)| u.satisfaction_weight()).scan(Weight::MAX, |min:&mut Weight, weight:Weight| {
*min = std::cmp::min(*min, weight);
Some(*min)
}).collect();

None
}

Expand Down

0 comments on commit 55452c5

Please sign in to comment.