Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use truncated subtraction in assignCoinsToChangeMaps. #4123

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/coin-selection/lib/Cardano/CoinSelection/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ assignCoinsToChangeMaps adaAvailable minCoinFor pairsAtStart
-- Calculate the amount of ada that remains after assigning the
-- minimum amount to each map. This should be safe, as we have
-- already determined that we have enough ada available:
adaRemaining = adaAvailable `Coin.distance` adaRequired
adaRemaining = adaAvailable <\> adaRequired
-- Partition any remaining ada according to the weighted
-- distribution of output coins that remain in our list:
outputCoinsRemaining = snd <$> (pair :| pairs)
Expand All @@ -1590,7 +1590,7 @@ assignCoinsToChangeMaps adaAvailable minCoinFor pairsAtStart
-- required amount of every asset map, but we do have an empty
-- asset map that is safe to drop. This will reduce the amount of
-- ada required by a small amount:
let adaRequired' = adaRequired `Coin.distance` minCoinFor m in
let adaRequired' = adaRequired <\> minCoinFor m in
loop adaRequired' (p :| ps)

(m, _) :| [] | TokenMap.isEmpty m && adaAvailable < adaRequired ->
Expand Down
Loading