Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarshimaitra committed Feb 28, 2024
1 parent d5b04fe commit 3b373ae
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! A blockchain-agnostic Rust Coinselection library


/// A [`OutputGroup`] represents an input candidate for Coinselection. This can either be a
/// single UTXO, or a group of UTXOs that should be spent together.
/// The library user is responsible for crafting this structure correctly. Incorrect representation of this
Expand All @@ -21,7 +20,7 @@ pub struct OutputGroup {
/// selection is not required.
/// Sequqence numbers are arbitrary index only to denote relative age of utxo group among a set of groups.
/// To denote the oldest utxo group, give them a sequence number of Some(0).
pub creation_sequqence: Option<u32>
pub creation_sequqence: Option<u32>,
}

/// A set of Options that guides the CoinSelection algorithms. These are inputs specified by the
Expand Down Expand Up @@ -59,8 +58,8 @@ pub enum ExcessStrategy {

/// Error Describing failure of a selection attempt.
#[derive(Debug)]
pub enum SelectionError{
SomethingWentWrong
pub enum SelectionError {
SomethingWentWrong,
}

/// Calculated waste for a specific selection.
Expand All @@ -69,43 +68,63 @@ pub enum SelectionError{
#[derive(Debug)]
pub struct WasteMetric(u64);


/// Perform Coinselection via Branch And Bound algorithm.
/// Return None, if no solution exists.
pub fn select_coin_bnb(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
pub fn select_coin_bnb(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
unimplemented!()
}

/// Perform Coinselection via Knapsack solver.
/// Return None, if no solution exists.
pub fn select_coin_knapsack(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
pub fn select_coin_knapsack(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
unimplemented!()
}


/// Perform Coinselection via Lowest Larger algorithm.
/// Return None, if no solution exists.
pub fn select_coin_lowestlarger(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
pub fn select_coin_lowestlarger(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
unimplemented!()
}


/// Perform Coinselection via First-In-First-Out algorithm.
/// Return None, if no solution exists.
pub fn select_coin_fifo(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
pub fn select_coin_fifo(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
unimplemented!()
}

/// Perform Coinselection via Single Random Draw.
/// Return None, if no solution exists.
pub fn select_coin_srd(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
pub fn select_coin_srd(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<Option<(Vec<u32>, WasteMetric)>, SelectionError> {
unimplemented!()
}


/// The Global Coinselection API that performs all the algorithms and proudeces result with least [WasteMetric].
/// At least one selection solution should be found.
pub fn select_coin_(inputs: Vec<OutputGroup>, opitons: CoinSelectionOpt, excess_strategy: ExcessStrategy) -> Result<(Vec<u32>, WasteMetric), SelectionError> {
pub fn select_coin_(
inputs: Vec<OutputGroup>,
opitons: CoinSelectionOpt,
excess_strategy: ExcessStrategy,
) -> Result<(Vec<u32>, WasteMetric), SelectionError> {
unimplemented!()
}

Expand Down

0 comments on commit 3b373ae

Please sign in to comment.