Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
Database / Persistence layer for the pool production.
Synopsis
-
data
DBLayer
m =
forall
stm.(
MonadFail
stm,
MonadIO
stm) =>
DBLayer
{
- putPoolProduction :: BlockHeader -> PoolId -> ExceptT ErrPointAlreadyExists stm ()
- readPoolProduction :: EpochNo -> stm ( Map PoolId [ BlockHeader ])
- readTotalProduction :: stm ( Map PoolId ( Quantity "block" Word64 ))
- putStakeDistribution :: EpochNo -> [( PoolId , Quantity "lovelace" Word64 )] -> stm ()
- readStakeDistribution :: EpochNo -> stm [( PoolId , Quantity "lovelace" Word64 )]
- readPoolProductionCursor :: Int -> stm [ BlockHeader ]
- readPoolLifeCycleStatus :: PoolId -> stm PoolLifeCycleStatus
- putPoolRegistration :: CertificatePublicationTime -> PoolRegistrationCertificate -> stm ()
- readPoolRegistration :: PoolId -> stm ( Maybe ( CertificatePublicationTime , PoolRegistrationCertificate ))
- putPoolRetirement :: CertificatePublicationTime -> PoolRetirementCertificate -> stm ()
- readPoolRetirement :: PoolId -> stm ( Maybe ( CertificatePublicationTime , PoolRetirementCertificate ))
- unfetchedPoolMetadataRefs :: Int -> stm [( PoolId , StakePoolMetadataUrl , StakePoolMetadataHash )]
- putFetchAttempt :: ( StakePoolMetadataUrl , StakePoolMetadataHash ) -> stm ()
- listRegisteredPools :: stm [ PoolId ]
- listRetiredPools :: EpochNo -> stm [ PoolRetirementCertificate ]
- listPoolLifeCycleData :: EpochNo -> stm [ PoolLifeCycleStatus ]
- putPoolMetadata :: StakePoolMetadataHash -> StakePoolMetadata -> stm ()
- removePoolMetadata :: stm ()
- readPoolMetadata :: stm ( Map StakePoolMetadataHash StakePoolMetadata )
- readSystemSeed :: stm StdGen
- rollbackTo :: SlotNo -> stm ()
- putDelistedPools :: [ PoolId ] -> stm ()
- readDelistedPools :: stm [ PoolId ]
- removePools :: [ PoolId ] -> stm ()
- removeRetiredPools :: EpochNo -> stm [ PoolRetirementCertificate ]
- putHeader :: BlockHeader -> stm ()
- listHeaders :: Int -> stm [ BlockHeader ]
- readSettings :: stm Settings
- putSettings :: Settings -> stm ()
- readLastMetadataGC :: stm ( Maybe POSIXTime )
- putLastMetadataGC :: POSIXTime -> stm ()
- cleanDB :: stm ()
- atomically :: forall a. stm a -> m a
- determinePoolLifeCycleStatus :: ( Ord publicationTime, Show publicationTime) => Maybe (publicationTime, PoolRegistrationCertificate ) -> Maybe (publicationTime, PoolRetirementCertificate ) -> PoolLifeCycleStatus
- newtype ErrPointAlreadyExists = ErrPointAlreadyExists BlockHeader
Interface
A Database interface for storing pool production in DB.
To use it, you will need the NamedFieldPuns extension and wrap operations
with
atomically
:
Example:
>>>
:set -XNamedFieldPuns
>>>
DBLayer{atomically,putPoolProduction} = db
>>>
atomically $ putPoolProduction blockHeader pool
This gives you the power to also run multiple operations atomically.
FIXME: Allowing
MonadIO
to enable logging also within db transactions.
Ideally, we should lower than constraint to only allow logging effects and
not any dragons in IO.
forall stm.( MonadFail stm, MonadIO stm) => DBLayer | |
|
Utilities
determinePoolLifeCycleStatus :: ( Ord publicationTime, Show publicationTime) => Maybe (publicationTime, PoolRegistrationCertificate ) -> Maybe (publicationTime, PoolRetirementCertificate ) -> PoolLifeCycleStatus Source #
Given the latest registration and retirement certificates for a pool, determine the pool's current life cycle status, based on the relative order in which the certificates were published.
If two certificates are supplied, then:
- the certificates must be from the same pool.
- the publication times must be non-equal.
Violating either of the above pre-conditions is a programming error.
This function determines order of precedence according to the "pool inference rule", as described in "A Formal Specification of the Cardano Ledger":
https://hydra.iohk.io/build/3202141/download/1/ledger-spec.pdf
Errors
newtype ErrPointAlreadyExists Source #
Forbidden operation was executed on an already existing slot
Instances
Eq ErrPointAlreadyExists Source # | |
Defined in Cardano.Pool.DB (==) :: ErrPointAlreadyExists -> ErrPointAlreadyExists -> Bool Source # (/=) :: ErrPointAlreadyExists -> ErrPointAlreadyExists -> Bool Source # |
|
Show ErrPointAlreadyExists Source # | |
Defined in Cardano.Pool.DB |