cardano-rpc
Safe HaskellNone
LanguageHaskell2010

Cardano.Rpc.Server.NodeKernelAccess

Synopsis

Documentation

data NodeKernelAccess Source #

In-process access to the node kernel. Constructed by cardano-node once consensus initialisation completes.

Constructors

NodeKernelAccess 

Fields

Instances

Instances details
Has (IORef (Maybe NodeKernelAccess)) RpcEnv Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.Monad

mkNodeKernelAccess Source #

Arguments

:: Monad m 
=> Tracer m Text

Tracer for unsupported block type warnings

-> BlockType blk

Block type witness

-> TopLevelConfig blk

Top-level consensus config (for system start, era history and the security parameter)

-> NodeKernel IO addrNTN addrNTC blk

Consensus node kernel

-> m (Maybe NodeKernelAccess) 

Construct NodeKernelAccess from a consensus NodeKernel. Returns Nothing and traces the block type for non-Cardano block types.

fetchBlock Source #

Arguments

:: MonadIO m 
=> NodeKernelAccess

Node kernel access handle

-> SlotNo

Block slot number

-> Hash BlockHeader

Block header hash

-> m (Maybe (ByteString, BlockInMode))

Raw CBOR bytes and the block in era context, or Nothing if not found

Fetch a raw block and its parsed era-contextualised form from ChainDB by slot and header hash.

grabNodeKernelAccess :: MonadRpc e m => m NodeKernelAccess Source #

Grab the current NodeKernelAccess from the environment, or throw gRPC UNAVAILABLE if the node kernel has not yet initialised.

data ChainChange Source #

A single instruction produced by a chain follower.

ChainApply carries the raw CBOR block bytes together with the same block parsed into its era context - exactly the pair fetchBlock returns. Consensus rollbacks are point-only: ChainRollBack never carries the blocks being rolled back, only the point to roll back to.

data ChainFollower Source #

A handle to a running chain follower.

Constructors

ChainFollower 

Fields

withFollower :: MonadUnliftIO m => NodeKernelAccess -> (ChainFollower -> m a) -> m a Source #

Run an action with a ChainFollower tracking the selected chain.

The follower and the resource registry backing it are closed on every exit path, including exceptions. The follower itself runs in IO, because the ChainDB handle is monomorphic, so the bracket runs there and the action is unlifted into it.

Creating a follower is cheap: a few in-memory STM operations, nothing proportional to chain length. The costs are steady-state instead. A caught-up follower receives an O(1) notification per adopted block. A follower catching up streams blocks from the ImmutableDB, paying a disk read and a deserialisation per block, with file handles owned by the registry. The node already runs one such follower per connected N2C ChainSync client, so one follower per stream scales the same way.