Skip to content

Commit b9faf88

Browse files
committed
Small refactor
Signed-off-by: Sasha Bogicevic <[email protected]>
1 parent 36618fe commit b9faf88

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

hydra-tx/src/Hydra/Tx/Deposit.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ capUTxO utxo target
125125
-- \| Helper function to recursively select and split UTxO outputs to reach the target value.
126126
go foundSoFar leftovers currentSum sorted
127127
| currentSum == target = (foundSoFar, leftovers)
128-
| null sorted = (foundSoFar, leftovers)
129128
| otherwise = case take 1 sorted of
130129
[] -> (foundSoFar, leftovers)
131130
(txIn, txOut) : _ ->
@@ -142,13 +141,11 @@ capUTxO utxo target
142141
-- Split the output to meet the target exactly.
143142
let cappedValue = target - currentSum
144143
leftoverVal = x - cappedValue
145-
newTxIn1 = txIn
146-
newTxIn2 = txIn
147144
cappedTxOut = updateTxOutValue txOut cappedValue
148145
leftoverTxOut = updateTxOutValue txOut leftoverVal
149146
in go
150-
(foundSoFar <> UTxO.singleton newTxIn1 cappedTxOut)
151-
(UTxO.difference leftovers (UTxO.singleton txIn txOut) <> UTxO.singleton newTxIn2 leftoverTxOut)
147+
(foundSoFar <> UTxO.singleton txIn cappedTxOut)
148+
(UTxO.difference leftovers (UTxO.singleton txIn txOut) <> UTxO.singleton txIn leftoverTxOut)
152149
(currentSum + cappedValue)
153150
(removeOne (txIn, txOut) sorted)
154151

0 commit comments

Comments
 (0)