plutus-chain-index-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.ChainIndex.Lib

Description

Using the chain index as a library.

A minimal example that just syncs the chain index:

withDefaultRunRequirements $ runReq -> do

    syncHandler <- defaultChainSyncHandler runReq

    syncChainIndex defaultConfig runReq syncHandler

    void getLine
Synopsis

Documentation

data RunRequirements Source #

The required arguments to run the chain index effects.

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 ': effs))) a -> Eff effs (Either ChainIndexError a) Source #

Handle the chain index effects from the set of all 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.

Constructors

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

Instances details
Show ChainSyncEvent Source # 
Instance details

Defined in Plutus.ChainIndex.Lib

storeFromBlockNo :: BlockNumber -> ChainSyncHandler -> ChainSyncHandler Source #

Changes the given ChainSyncHandler to only store transactions with a block number no smaller than the given one.

filterTxs Source #

Arguments

:: (ChainIndexTx -> Bool)

Only process transactions for which this function returns True.

-> (ChainIndexTx -> Bool)

From those, only store transactions for which this function returns True.

-> ChainSyncHandler

The ChainSyncHandler on which the returned ChainSyncHandler is based.

-> ChainSyncHandler 

Changes the given ChainSyncHandler to only process and store certain transactions.

Utils

getTipSlot :: ChainIndexConfig -> IO SlotNo Source #

Get the slot number of the current tip of the node.