plutus-chain-index-1.2.0.0
Safe Haskell None
Language Haskell2010

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

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

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.

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 ( Maybe SlotNo ) Source #

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