Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
An implementation of the production pool database using only pure functions.
These functions and types model the behaviour of the SQLite database backend, and are used for QuickCheck state machine testing, and the MVar database backend.
Synopsis
-
data
PoolDatabase
=
PoolDatabase
{
- pools :: !( Map PoolId [ BlockHeader ])
- distributions :: !( Map EpochNo [( PoolId , Quantity "lovelace" Word64 )])
- owners :: !( Map PoolId [ PoolOwner ])
- registrations :: !( Map ( CertificatePublicationTime , PoolId ) PoolRegistrationCertificate )
- retirements :: !( Map ( CertificatePublicationTime , PoolId ) PoolRetirementCertificate )
- delisted :: !( Set PoolId )
- metadata :: !( Map StakePoolMetadataHash StakePoolMetadata )
- fetchAttempts :: !( Map ( StakePoolMetadataUrl , StakePoolMetadataHash ) Int )
- seed :: !SystemSeed
- blockHeaders :: [ BlockHeader ]
- settings :: Settings
- internalState :: InternalState
- emptyPoolDatabase :: PoolDatabase
- type ModelOp a = StateT PoolDatabase ( Either PoolErr ) a
- newtype PoolErr = PointAlreadyExists BlockHeader
- mCleanDatabase :: ModelOp ()
- mCleanPoolMetadata :: ModelOp ()
- mPutPoolProduction :: BlockHeader -> PoolId -> ModelOp ()
- mPutHeader :: BlockHeader -> ModelOp ()
- mListHeaders :: Int -> ModelOp [ BlockHeader ]
- mReadPoolProduction :: TimeInterpreter Identity -> EpochNo -> ModelOp ( Map PoolId [ BlockHeader ])
- mReadTotalProduction :: ModelOp ( Map PoolId ( Quantity "block" Word64 ))
- mPutStakeDistribution :: EpochNo -> [( PoolId , Quantity "lovelace" Word64 )] -> ModelOp ()
- mReadStakeDistribution :: EpochNo -> ModelOp [( PoolId , Quantity "lovelace" Word64 )]
- mReadPoolMetadata :: ModelOp ( Map StakePoolMetadataHash StakePoolMetadata )
- mPutPoolRegistration :: CertificatePublicationTime -> PoolRegistrationCertificate -> ModelOp ()
- mReadPoolRegistration :: PoolId -> ModelOp ( Maybe ( CertificatePublicationTime , PoolRegistrationCertificate ))
- mPutPoolRetirement :: CertificatePublicationTime -> PoolRetirementCertificate -> ModelOp ()
- mReadPoolRetirement :: PoolId -> ModelOp ( Maybe ( CertificatePublicationTime , PoolRetirementCertificate ))
- mUnfetchedPoolMetadataRefs :: Int -> ModelOp [( PoolId , StakePoolMetadataUrl , StakePoolMetadataHash )]
- mPutDelistedPools :: [ PoolId ] -> ModelOp ()
- mPutFetchAttempt :: ( StakePoolMetadataUrl , StakePoolMetadataHash ) -> ModelOp ()
- mPutPoolMetadata :: StakePoolMetadataHash -> StakePoolMetadata -> ModelOp ()
- mListPoolLifeCycleData :: EpochNo -> ModelOp [ PoolLifeCycleStatus ]
- mListRegisteredPools :: ModelOp [ PoolId ]
- mListRetiredPools :: EpochNo -> ModelOp [ PoolRetirementCertificate ]
- mReadPoolLifeCycleStatus :: PoolId -> ModelOp PoolLifeCycleStatus
- mReadSystemSeed :: PoolDatabase -> IO ( StdGen , PoolDatabase )
- mRollbackTo :: TimeInterpreter Identity -> SlotNo -> ModelOp ()
- mReadCursor :: Int -> ModelOp [ BlockHeader ]
- mRemovePools :: [ PoolId ] -> ModelOp ()
- mReadDelistedPools :: ModelOp [ PoolId ]
- mRemoveRetiredPools :: EpochNo -> ModelOp [ PoolRetirementCertificate ]
- mReadSettings :: ModelOp Settings
- mPutSettings :: Settings -> ModelOp ()
- mPutLastMetadataGC :: POSIXTime -> ModelOp ()
- mReadLastMetadataGC :: ModelOp ( Maybe POSIXTime )
Model Types
data PoolDatabase Source #
PoolDatabase | |
|
Instances
Eq PoolDatabase Source # | |
Defined in Cardano.Pool.DB.Model (==) :: PoolDatabase -> PoolDatabase -> Bool Source # (/=) :: PoolDatabase -> PoolDatabase -> Bool Source # |
|
Show PoolDatabase Source # | |
Defined in Cardano.Pool.DB.Model |
|
Generic PoolDatabase Source # | |
Defined in Cardano.Pool.DB.Model from :: PoolDatabase -> Rep PoolDatabase x Source # to :: Rep PoolDatabase x -> PoolDatabase Source # |
|
type Rep PoolDatabase Source # | |
Defined in Cardano.Pool.DB.Model |
emptyPoolDatabase :: PoolDatabase Source #
Produces an empty model pool production database.
Model Operation Types
Model pool database functions
mCleanDatabase :: ModelOp () Source #
mCleanPoolMetadata :: ModelOp () Source #
mPutPoolProduction :: BlockHeader -> PoolId -> ModelOp () Source #
mPutHeader :: BlockHeader -> ModelOp () Source #
mListHeaders :: Int -> ModelOp [ BlockHeader ] Source #
mReadPoolProduction :: TimeInterpreter Identity -> EpochNo -> ModelOp ( Map PoolId [ BlockHeader ]) Source #
mPutStakeDistribution :: EpochNo -> [( PoolId , Quantity "lovelace" Word64 )] -> ModelOp () Source #
mPutPoolRegistration :: CertificatePublicationTime -> PoolRegistrationCertificate -> ModelOp () Source #
mReadPoolRegistration :: PoolId -> ModelOp ( Maybe ( CertificatePublicationTime , PoolRegistrationCertificate )) Source #
mPutPoolRetirement :: CertificatePublicationTime -> PoolRetirementCertificate -> ModelOp () Source #
mReadPoolRetirement :: PoolId -> ModelOp ( Maybe ( CertificatePublicationTime , PoolRetirementCertificate )) Source #
mUnfetchedPoolMetadataRefs :: Int -> ModelOp [( PoolId , StakePoolMetadataUrl , StakePoolMetadataHash )] Source #
mPutDelistedPools :: [ PoolId ] -> ModelOp () Source #
mPutFetchAttempt :: ( StakePoolMetadataUrl , StakePoolMetadataHash ) -> ModelOp () Source #
mPutPoolMetadata :: StakePoolMetadataHash -> StakePoolMetadata -> ModelOp () Source #
mListRegisteredPools :: ModelOp [ PoolId ] Source #
mReadSystemSeed :: PoolDatabase -> IO ( StdGen , PoolDatabase ) Source #
mRollbackTo :: TimeInterpreter Identity -> SlotNo -> ModelOp () Source #
mReadCursor :: Int -> ModelOp [ BlockHeader ] Source #
mRemovePools :: [ PoolId ] -> ModelOp () Source #
mReadDelistedPools :: ModelOp [ PoolId ] Source #
mPutSettings :: Settings -> ModelOp () Source #
mPutLastMetadataGC :: POSIXTime -> ModelOp () Source #