Skip to content

Commit

Permalink
Improve splitUTxO
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Jun 12, 2024
1 parent 0beaeb8 commit 4a273e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ genDecrementTx numParties = do
splitUTxO :: UTxO -> (UTxO, UTxO)
splitUTxO utxo =
let pairs = UTxO.pairs utxo
toDecommit = List.head $ List.filter ((> 0) . selectLovelace . txOutValue . snd) pairs
restOfUTxO = List.filter ((fst toDecommit /=) . fst) pairs
in (UTxO.fromPairs restOfUTxO, UTxO.singleton toDecommit)
in case uncons $ List.filter ((> 0) . selectLovelace . txOutValue . snd) pairs of
Nothing -> (mempty, mempty)
Just (toDecommit, rest) -> (UTxO.fromPairs rest, UTxO.singleton toDecommit)

genCloseTx :: Int -> Gen (ChainContext, OpenState, Tx, ConfirmedSnapshot Tx)
genCloseTx numParties = do
Expand Down

0 comments on commit 4a273e2

Please sign in to comment.