Skip to content

Commit

Permalink
Switch to if/then/else instead of case guards
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Feb 21, 2023
1 parent fce9a0f commit d7d2eed
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,15 @@ onOpenNetworkReqSn env ledger st otherParty sn txs =
)
[NetworkEffect $ AckSn party snapshotSignature sn]
where
requireReqSn cont
| sn == seenSn + 1 && isLeader parameters otherParty sn = cont
| otherwise = Error $ RequireFailed "requireReqSn"
requireReqSn continue =
if sn == seenSn + 1 && isLeader parameters otherParty sn
then continue
else Error $ RequireFailed "requireReqSn"

waitNoSnapshotInFlight cont
| confSn == seenSn = cont
| otherwise = Wait $ WaitOnSnapshotNumber seenSn
waitNoSnapshotInFlight continue =
if confSn == seenSn
then continue
else Wait $ WaitOnSnapshotNumber seenSn

waitApplyTxs cont =
case applyTransactions ledger confirmedUTxO txs of
Expand Down Expand Up @@ -831,14 +833,15 @@ onOpenNetworkAckSn env openState otherParty snapshotSignature sn =
where
seenSn = seenSnapshotNumber seenSnapshot

requireAckSn sigs cont
| sn `elem` [seenSn, seenSn + 1] && not (Map.member otherParty sigs) = cont
| otherwise = Error $ RequireFailed "requireReqSn"
requireAckSn sigs continue =
if sn `elem` [seenSn, seenSn + 1] && not (Map.member otherParty sigs)
then continue
else Error $ RequireFailed "requireReqSn"

waitOnSeenSnapshot cont =
waitOnSeenSnapshot continue =
case seenSnapshot of
SeenSnapshot snapshot sigs
| seenSn == sn -> cont snapshot sigs
| seenSn == sn -> continue snapshot sigs
_ -> Wait WaitOnSeenSnapshot

ifAllMembersHaveSigned snapshot sigs' cont =
Expand Down

0 comments on commit d7d2eed

Please sign in to comment.