mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
Coin selection cleanups (#607)
* coin selection (cleanup): - rename `selection_strategy: bool` and `default_strategy: bool` - use `selection_strategy_is_use_all` outside, and `use_all` inside wallet types (narrowly escaping rustfmt!)
This commit is contained in:
parent
8b2f9503c9
commit
d28f37d5b3
2 changed files with 13 additions and 13 deletions
|
@ -35,7 +35,7 @@ pub fn issue_send_tx(
|
|||
minimum_confirmations: u64,
|
||||
dest: String,
|
||||
max_outputs: usize,
|
||||
selection_strategy: bool,
|
||||
selection_strategy_is_use_all: bool,
|
||||
) -> Result<(), Error> {
|
||||
checker::refresh_outputs(config, keychain)?;
|
||||
|
||||
|
@ -53,7 +53,7 @@ pub fn issue_send_tx(
|
|||
minimum_confirmations,
|
||||
lock_height,
|
||||
max_outputs,
|
||||
selection_strategy,
|
||||
selection_strategy_is_use_all,
|
||||
)?;
|
||||
/*
|
||||
* -Sender picks random blinding factors for all outputs it participates in, computes total blinding excess xS
|
||||
|
@ -162,7 +162,7 @@ fn build_send_tx(
|
|||
minimum_confirmations: u64,
|
||||
lock_height: u64,
|
||||
max_outputs: usize,
|
||||
default_strategy: bool,
|
||||
selection_strategy_is_use_all: bool,
|
||||
) -> Result<(Transaction, BlindingFactor, Vec<OutputData>, Identifier), Error> {
|
||||
let key_id = keychain.clone().root_key_id();
|
||||
|
||||
|
@ -174,7 +174,7 @@ fn build_send_tx(
|
|||
current_height,
|
||||
minimum_confirmations,
|
||||
max_outputs,
|
||||
default_strategy,
|
||||
selection_strategy_is_use_all,
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@ impl WalletData {
|
|||
current_height: u64,
|
||||
minimum_confirmations: u64,
|
||||
max_outputs: usize,
|
||||
default_strategy: bool,
|
||||
select_all: bool,
|
||||
) -> Vec<OutputData> {
|
||||
// first find all eligible outputs based on number of confirmations
|
||||
let mut eligible = self.outputs
|
||||
|
@ -554,8 +554,8 @@ impl WalletData {
|
|||
// So the wallet considers max_outputs more of a soft limit.
|
||||
if eligible.len() > max_outputs {
|
||||
for window in eligible.windows(max_outputs) {
|
||||
let eligible = window.iter().cloned().collect::<Vec<_>>();
|
||||
if let Some(outputs) = self.select_from(amount, default_strategy, eligible) {
|
||||
let windowed_eligibles = window.iter().cloned().collect::<Vec<_>>();
|
||||
if let Some(outputs) = self.select_from(amount, select_all, windowed_eligibles) {
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ impl WalletData {
|
|||
return outputs;
|
||||
}
|
||||
} else {
|
||||
if let Some(outputs) = self.select_from(amount, default_strategy, eligible.clone()) {
|
||||
if let Some(outputs) = self.select_from(amount, select_all, eligible.clone()) {
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ impl WalletData {
|
|||
eligible.iter().take(max_outputs).cloned().collect()
|
||||
}
|
||||
|
||||
// Select the full list of outputs if we are using the default strategy.
|
||||
// Select the full list of outputs if we are using the select_all strategy.
|
||||
// Otherwise select just enough outputs to cover the desired amount.
|
||||
fn select_from(
|
||||
&self,
|
||||
|
|
Loading…
Reference in a new issue