Skip to content

Commit

Permalink
Simplify determinePoolRegistrationStatus pattern matching.
Browse files Browse the repository at this point in the history
In response to review feedback:

#1847 (comment)
  • Loading branch information
jonathanknowles committed Jul 10, 2020
1 parent 8681dbe commit 9e63282
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/core/src/Cardano/Pool/DB.hs
Expand Up @@ -224,23 +224,19 @@ determinePoolRegistrationStatus
=> Maybe (certificatePublicationTime, PoolRegistrationCertificate)
-> Maybe (certificatePublicationTime, PoolRetirementCertificate)
-> PoolRegistrationStatus
determinePoolRegistrationStatus = f
where
f Nothing _ =
determinePoolRegistrationStatus mReg mRet = case (mReg, mRet) of
(Nothing, _) ->
PoolNotRegistered
f (Just (_, regCert)) Nothing =
(Just (_, regCert), Nothing) ->
PoolRegistered regCert
f (Just reg) (Just ret) =
g reg ret

g (regTime, regCert) (retTime, retCert)
| regPoolId /= retPoolId =
(Just (regTime, regCert), Just (retTime, retCert))
| regPoolId /= retPoolId ->
differentPoolsError
| regTime > retTime =
| regTime > retTime ->
PoolRegistered regCert
| regTime < retTime =
| regTime < retTime ->
PoolRegisteredAndRetired regCert retCert
| otherwise =
| otherwise ->
timeCollisionError
where
regPoolId = view #poolId regCert
Expand Down

0 comments on commit 9e63282

Please sign in to comment.