Skip to content

Commit

Permalink
Simplify distributeSurplusDelta by pattern matching directly on cha…
Browse files Browse the repository at this point in the history
…nge list.

In response to review feedback:

#3238 (comment)
  • Loading branch information
jonathanknowles committed Apr 20, 2022
1 parent b6d2189 commit 8eccfc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ import Data.Kind
import Data.Map.Strict
( Map, (!) )
import Data.Maybe
( fromMaybe, listToMaybe, mapMaybe )
( fromMaybe, mapMaybe )
import Data.Quantity
( Quantity (..) )
import Data.Set
Expand Down Expand Up @@ -1520,13 +1520,13 @@ distributeSurplusDelta
-> TxFeeAndChange [Coin]
-> Either ErrMoreSurplusNeeded (TxFeeAndChange [Coin])
distributeSurplusDelta feePolicy surplus (TxFeeAndChange fee change) =
case listToMaybe change of
Just firstChange ->
case change of
changeHead : changeTail ->
distributeSurplusDeltaWithOneChangeCoin feePolicy surplus
(TxFeeAndChange fee firstChange)
(TxFeeAndChange fee changeHead)
<&> mapTxFeeAndChange id
((: replicate (length change - 1) (Coin 0)))
Nothing ->
(: (Coin 0 <$ changeTail))
[] ->
burnSurplusAsFees feePolicy surplus
(TxFeeAndChange fee ())
<&> mapTxFeeAndChange id
Expand Down

0 comments on commit 8eccfc5

Please sign in to comment.