Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Dec 14, 2024
1 parent 3bfabb3 commit 92117f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions benches/coin_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct Utxo {
impl WeightedUtxo for Utxo {
fn satisfaction_weight(&self) -> Weight { self.satisfaction_weight }

fn weight(&self) -> Weight { Weight::ZERO }
fn value(&self) -> Amount { self.output.value }
}

Expand Down
2 changes: 1 addition & 1 deletion src/branch_and_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub fn select_coins_bnb<Utxo: WeightedUtxo>(
iteration += 1;
}

index_to_utxo_list(best_selection, w_utxos);
index_to_utxo_list(best_selection, w_utxos)
}

fn index_to_utxo_list<Utxo: WeightedUtxo>(
Expand Down
8 changes: 3 additions & 5 deletions src/coin_grinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/// # Parameters
///
/// * target: Target spend `Amount`
/// * change_target: A bound on the `Amount` to increase target by with which to create a change
/// output.
/// * change_target: A bound on the `Amount` to increase target by with which to create a change output.
/// * max_selection_weight: Maximum allowable selection weight.
/// * fee_rate: Needed to calculate the effective_value.
/// * weighted_utxos: The candidate Weighted UTXOs from which to choose a selection from
Expand Down Expand Up @@ -53,7 +52,6 @@ use bitcoin::amount::CheckedSum;
/// - Not enough potential amount to meet the target, etc
/// - Target Amount is zero (no match possible)
/// - UTXO space was searched succefully however no match was found
// The sum of UTXO amounts after this UTXO index, e.g. lookahead[5] = Σ(UTXO[6+].amount)
fn build_lookahead<Utxo: WeightedUtxo>(lookahead: Vec<(Amount, &Utxo)>, available_value: Amount) -> Vec<Amount>{
lookahead.iter().map(|(e, _w)| e).scan(available_value, |state, &u| {
Expand Down Expand Up @@ -318,7 +316,7 @@ mod tests {
let eff_values: Vec<(Amount, &Utxo)> = calc_effective_values(&utxos, FeeRate::ZERO);
let min_group_weight = build_min_group_weight(eff_values.clone());

let expect: Vec<Weight> = vec![
let expect: Vec<Weight> = [
4u64,
4u64,
8u64,
Expand All @@ -341,7 +339,7 @@ mod tests {
let available_value = Amount::from_str("26 sats").unwrap();
let lookahead = build_lookahead(eff_values, available_value);

let expect: Vec<Amount> = vec![
let expect: Vec<Amount> = [
"16 sats",
"9 sats",
"4 sats",
Expand Down

0 comments on commit 92117f9

Please sign in to comment.