diff --git a/src/lib.rs b/src/lib.rs index faa1d66..cddd292 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ pub use crate::single_random_draw::select_coins_srd; /// Trait that a UTXO struct must implement to be used as part of the coin selection /// algorithm. -pub trait Utxo: Clone { +pub trait Utxo { /// Return the value of the UTXO. fn get_value(&self) -> u64; @@ -48,7 +48,7 @@ pub fn select_coins( cost_of_change: u64, fee_rate: u64, utxo_pool: &mut [T], -) -> Option> { +) -> Option> { let spend = Spend::new(fee_rate); match select_coins_bnb(target, cost_of_change, utxo_pool) { diff --git a/src/single_random_draw.rs b/src/single_random_draw.rs index 9ad4346..d14323e 100644 --- a/src/single_random_draw.rs +++ b/src/single_random_draw.rs @@ -16,7 +16,7 @@ use rand::{seq::SliceRandom, thread_rng}; /// Requires compilation with the "rand" feature. #[cfg(any(test, feature = "rand"))] #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] -pub fn select_coins_srd(target: u64, utxo_pool: &mut [T], spend: Spend) -> Option> { +pub fn select_coins_srd(target: u64, utxo_pool: &mut [T], spend: Spend) -> Option> { utxo_pool.shuffle(&mut thread_rng()); let mut sum = 0; @@ -30,8 +30,7 @@ pub fn select_coins_srd(target: u64, utxo_pool: &mut [T], spend: Spend) sum += spend.get_effective_value(*x); true }) - .cloned() - .collect::>(); + .collect::>(); if sum >= target { return Some(res);