Safe Haskell | None |
---|---|
Language | Haskell2010 |
Using the chain index as a library.
A minimal example that just syncs the chain index:
withDefaultRunRequirements
$ runReq -> do syncHandler <-defaultChainSyncHandler
runReqsyncChainIndex
defaultConfig
runReq syncHandler void getLine
Synopsis
-
data
RunRequirements
=
RunRequirements
{
- trace :: Trace IO ( PrettyObject ChainIndexLog )
- stateTVar :: TVar ChainIndexState
- pool :: Pool Connection
- securityParam :: Int
- withRunRequirements :: Configuration -> ChainIndexConfig -> ( RunRequirements -> IO ()) -> IO ()
- withDefaultRunRequirements :: ( RunRequirements -> IO ()) -> IO ()
- defaultLoggingConfig :: IO Configuration
- defaultConfig :: ChainIndexConfig
- handleChainIndexEffects :: forall (effs :: [ Type -> Type ]) a. ( LastMember IO effs, Member ( LogMsg ChainIndexLog ) effs) => RunRequirements -> Eff ( ChainIndexQueryEffect ': ( ChainIndexControlEffect ': ( BeamEffect Sqlite ': effs))) a -> Eff effs ( Either ChainIndexError a)
- runChainIndexEffects :: RunRequirements -> Eff '[ ChainIndexQueryEffect , ChainIndexControlEffect , BeamEffect Sqlite ] a -> IO ( Either ChainIndexError a)
- syncChainIndex :: ChainIndexConfig -> RunRequirements -> ChainSyncHandler -> IO ()
- type ChainSyncHandler = ChainSyncEvent -> IO ()
- data ChainSyncEvent
- type EventsQueue = TBMQueue ChainSyncEvent
- storeChainSyncHandler :: EventsQueue -> ChainSyncHandler
- storeFromBlockNo :: BlockNumber -> ChainSyncHandler -> ChainSyncHandler
- filterTxs :: ( ChainIndexTx -> Bool ) -> ( ChainIndexTx -> Bool ) -> ChainSyncHandler -> ChainSyncHandler
- runChainIndexDuringSync :: RunRequirements -> Eff '[ ChainIndexQueryEffect , ChainIndexControlEffect , BeamEffect Sqlite ] a -> IO ( Maybe a)
- getTipSlot :: ChainIndexConfig -> IO ( Maybe SlotNo )
Documentation
data RunRequirements Source #
The required arguments to run the chain index effects.
RunRequirements | |
|
withRunRequirements :: Configuration -> ChainIndexConfig -> ( RunRequirements -> IO ()) -> IO () Source #
Generate the requirements to run the chain index effects given logging configuration and chain index configuration.
withDefaultRunRequirements :: ( RunRequirements -> IO ()) -> IO () Source #
Generate the requirements to run the chain index effects given default configurations.
defaultLoggingConfig :: IO Configuration Source #
The default logging configuration.
defaultConfig :: ChainIndexConfig Source #
These settings work with the main testnet
Chain index effects
handleChainIndexEffects :: forall (effs :: [ Type -> Type ]) a. ( LastMember IO effs, Member ( LogMsg ChainIndexLog ) effs) => RunRequirements -> Eff ( ChainIndexQueryEffect ': ( ChainIndexControlEffect ': ( BeamEffect Sqlite ': effs))) a -> Eff effs ( Either ChainIndexError a) Source #
Handle the chain index effects from the set of all effects.
runChainIndexEffects :: RunRequirements -> Eff '[ ChainIndexQueryEffect , ChainIndexControlEffect , BeamEffect Sqlite ] a -> IO ( Either ChainIndexError a) Source #
Run the chain index effects.
Chain synchronisation
syncChainIndex :: ChainIndexConfig -> RunRequirements -> ChainSyncHandler -> IO () Source #
Synchronise the chain index with the node using the given handler.
Synchronisation handlers
type ChainSyncHandler = ChainSyncEvent -> IO () Source #
A handler for chain synchronisation events.
data ChainSyncEvent Source #
Chain synchronisation events.
Resume Point |
Resume from the given point |
RollForward ChainSyncBlock Tip |
Append the given block. The tip is the current tip of the node, which is newer than the tip of the block during syncing. |
RollBackward Point Tip |
Roll back to the given point. The tip is current tip of the node. |
Instances
Show ChainSyncEvent Source # | |
Defined in Plutus.ChainIndex.Lib |
type EventsQueue = TBMQueue ChainSyncEvent Source #
storeFromBlockNo :: BlockNumber -> ChainSyncHandler -> ChainSyncHandler Source #
Changes the given
ChainSyncHandler
to only store transactions with a block number no smaller than the given one.
:: ( ChainIndexTx -> Bool ) |
Only process transactions for which this function returns
|
-> ( ChainIndexTx -> Bool ) |
From those, only store transactions for which this function returns
|
-> ChainSyncHandler |
The
|
-> ChainSyncHandler |
Changes the given
ChainSyncHandler
to only process and store certain transactions.
runChainIndexDuringSync :: RunRequirements -> Eff '[ ChainIndexQueryEffect , ChainIndexControlEffect , BeamEffect Sqlite ] a -> IO ( Maybe a) Source #
Utils
getTipSlot :: ChainIndexConfig -> IO ( Maybe SlotNo ) Source #
Get the slot number of the current tip of the node.