Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ledger related queries
Synopsis
- withCommittedBlock :: HasDataStorage env => BlockHash -> (forall t. Typeable t => Block t Committed -> RIO env a) -> RIO env (Maybe a)
- withValidatedBlock :: HasDataStorage env => SignedBlock -> (forall t. Typeable t => Block t Validated -> RIO env a) -> RIO env (Either BlockValidationError a)
- commitValidatedBlock :: (HasDataStorage env, Typeable t) => Block t Validated -> RIO env (Maybe BlockValidationError)
Documentation
:: HasDataStorage env | |
=> BlockHash | Hash of the block we are trying to look up |
-> (forall t. Typeable t => Block t Committed -> RIO env a) | A handler function that knows how to handle each type of block. We need
this approach, since there is no way to know until we look up in the
database, what type of block the supplied |
-> RIO env (Maybe a) |
:: HasDataStorage env | |
=> SignedBlock | |
-> (forall t. Typeable t => Block t Validated -> RIO env a) | A function that will be applied to the validated block. It is up to the
caller to decide how to handle a block of each type. See |
-> RIO env (Either BlockValidationError a) |
Convert SignedBlock
into Block
while making sure that the block is indeed correct
and does not violate any validation checks.
Note: This function does not write anything to the database.
commitValidatedBlock :: (HasDataStorage env, Typeable t) => Block t Validated -> RIO env (Maybe BlockValidationError) #
Take a Validated block of any type and use it to update the current state in the database. The block will undergo minimlal validation, namely it will only checks the values that would indicate that the extected state has changed since the validation. For example if the previous BlockHash has changed, it would immediately invalidate the block.