Skip to content

Commit

Permalink
Use NamedFieldPuns in mkCoinSelection.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed May 12, 2020
1 parent a842a82 commit d7b7c09
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/library/Cardano/CoinSelection/Algorithm/Migration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ selectCoins options (BatchSize batchSize) utxo =
-- Note that the selection may look a bit weird at first sight as it has
-- no outputs (we are paying everything to ourselves!).
mkCoinSelection :: [CoinMapEntry i] -> CoinSelection i o
mkCoinSelection inps = CoinSelection
{ inputs = coinMapFromList inps
, outputs = mempty
, change =
let chgs = mapMaybe (noDust . entryValue) inps
in if null chgs then [C.succ threshold] else chgs
}
mkCoinSelection inputEntries = CoinSelection {inputs, outputs, change}
where
inputs = coinMapFromList inputEntries
outputs = mempty
change =
let chgs = mapMaybe (noDust . entryValue) inputEntries
in if null chgs then [C.succ threshold] else chgs
threshold = unDustThreshold dustThreshold
noDust :: Coin -> Maybe Coin
noDust c
Expand Down

0 comments on commit d7b7c09

Please sign in to comment.