Skip to content

Commit

Permalink
Provide SQLite implementation of listRetiredPools operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Aug 13, 2020
1 parent 7910adf commit e29706a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import Cardano.Pool.DB.Sqlite.TH

import qualified Data.Map.Strict as Map
import qualified Data.Text as T
import qualified Data.Text.Class as T
import qualified Database.Sqlite as Sqlite

-- | Return the preferred @FilePath@ for the stake pool .sqlite file, given a
Expand Down Expand Up @@ -354,7 +355,19 @@ newDBLayer trace fp timeInterpreter = do
, Desc PoolRegistrationSlotInternalIndex
]

, listRetiredPools = \_epochNo -> pure []
, listRetiredPools = \epochNo -> do
let query = T.unwords
[ "SELECT * FROM "
, databaseViewName activePoolRetirements
, "WHERE retirement_epoch <="
, T.toText epochNo
, ";"
]
let safeCast (Single poolId, Single retirementEpoch) =
PoolRetirementCertificate
<$> fromPersistValue poolId
<*> fromPersistValue retirementEpoch
rights . fmap safeCast <$> rawSql query []

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

0 comments on commit e29706a

Please sign in to comment.