Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Jul 29, 2021
1 parent 6eaf2b6 commit 80725d3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/core/src/Cardano/Wallet/Primitive/CoinSelection/Collateral.hs
Expand Up @@ -102,9 +102,8 @@ selectCollateralSmallest params =
SelectCollateralResult <$> smallestValidCombination
where
smallestValidCombination :: Maybe (Map inputId Coin)
smallestValidCombination
= listToMaybe
$ L.sortOn F.fold validCombinations
smallestValidCombination =
listToMaybe $ L.sortOn F.fold validCombinations
where
validCombinations :: [Map inputId Coin]
validCombinations = mapMaybe smallestValidCombinationOfSize
Expand Down Expand Up @@ -159,21 +158,21 @@ selectCollateralLargest params =
largestCombinationAvailable :: Map inputId Coin
largestCombinationAvailable =
coinsAvailable
& Map.toList
& L.sortOn (Down . snd)
& L.take maximumCollateralEntryCount
& Map.fromList
& Map.toList
& L.sortOn (Down . snd)
& L.take maximumCollateralEntryCount
& Map.fromList

smallestValidSubmapOfLargestCombinationAvailable :: Maybe (Map inputId Coin)
smallestValidSubmapOfLargestCombinationAvailable =
largestCombinationAvailable
& submaps
& Set.toList
& fmap (\ics -> (ics, F.fold ics))
& L.sortOn snd
& L.dropWhile ((< minimumCollateralAmount) . snd)
& fmap fst
& listToMaybe
& submaps
& Set.toList
& fmap (\ics -> (ics, F.fold ics))
& L.sortOn snd
& L.dropWhile ((< minimumCollateralAmount) . snd)
& fmap fst
& listToMaybe

SelectCollateralParams
{ coinsAvailable
Expand Down

0 comments on commit 80725d3

Please sign in to comment.