gini-storage-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Gini.Storage.Query

Description

Ledger related queries

Synopsis

Documentation

withCommittedBlock #

Arguments

:: 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 BlockHash refers to. See handleBlock for a helper function to build such handlers.

-> RIO env (Maybe a) 

Lookup a block by its hash value and apply an action to it. Returns Nothing if such block does not exist or the node is a LightNode and does not retain any historical data.

withValidatedBlock #

Arguments

:: 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 handleBlock for help on constructing such function

-> 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.