Skip to content

Commit

Permalink
Add skeleton listRetiredPools pool DB operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Aug 11, 2020
1 parent 913133e commit ee08a8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/core/src/Cardano/Pool/DB.hs
Expand Up @@ -171,6 +171,12 @@ data DBLayer m = forall stm. (MonadFail stm, MonadIO stm) => DBLayer
-- map we would get from 'readPoolProduction' because not all registered
-- pools have necessarily produced any block yet!

, listRetiredPools
:: EpochNo
-> stm [PoolRetirementCertificate]
-- ^ List all pools with an active retirement epoch that is earlier
-- than or equal to the specified epoch.

, putPoolMetadata
:: StakePoolMetadataHash
-> StakePoolMetadata
Expand Down
4 changes: 4 additions & 0 deletions lib/core/src/Cardano/Pool/DB/MVar.hs
Expand Up @@ -25,6 +25,7 @@ import Cardano.Pool.DB.Model
, emptyPoolDatabase
, mCleanPoolProduction
, mListRegisteredPools
, mListRetiredPools
, mPutFetchAttempt
, mPutPoolMetadata
, mPutPoolProduction
Expand Down Expand Up @@ -115,6 +116,9 @@ newDBLayer timeInterpreter = do
, listRegisteredPools =
modifyMVar db (pure . swap . mListRegisteredPools)

, listRetiredPools = \epochNo ->
modifyMVar db (pure . swap . mListRetiredPools epochNo)

, putPoolMetadata = \a0 a1 ->
void $ alterPoolDB (const Nothing) db (mPutPoolMetadata a0 a1)

Expand Down
7 changes: 7 additions & 0 deletions lib/core/src/Cardano/Pool/DB/Model.hs
Expand Up @@ -47,6 +47,7 @@ module Cardano.Pool.DB.Model
, mPutFetchAttempt
, mPutPoolMetadata
, mListRegisteredPools
, mListRetiredPools
, mReadSystemSeed
, mRollbackTo
, mReadCursor
Expand Down Expand Up @@ -260,6 +261,12 @@ mListRegisteredPools :: PoolDatabase -> ([PoolId], PoolDatabase)
mListRegisteredPools db@PoolDatabase{registrations} =
( snd <$> Map.keys registrations, db )

mListRetiredPools
:: EpochNo
-> PoolDatabase
-> ([PoolRetirementCertificate], PoolDatabase)
mListRetiredPools _epochNo db = ([], db)

mUnfetchedPoolMetadataRefs
:: Int
-> ModelPoolOp [(PoolId, StakePoolMetadataUrl, StakePoolMetadataHash)]
Expand Down
2 changes: 2 additions & 0 deletions lib/core/src/Cardano/Pool/DB/Sqlite.hs
Expand Up @@ -354,6 +354,8 @@ newDBLayer trace fp timeInterpreter = do
, Desc PoolRegistrationSlotInternalIndex
]

, listRetiredPools = \_epochNo -> pure []

, rollbackTo = \point -> do
-- TODO(ADP-356): What if the conversion blocks or fails?
--
Expand Down

0 comments on commit ee08a8f

Please sign in to comment.