cardano-api
Safe HaskellNone
LanguageHaskell2010

Cardano.Api.ChainSync.Client

Synopsis

Protocol type for the client

The protocol states from the point of view of the client.

newtype ChainSyncClient header point tip (m :: Type -> Type) a Source #

A chain sync protocol client, on top of some effect m. The first choice of request is within that m.

Constructors

ChainSyncClient 

Fields

data ClientStIdle header point tip (m :: Type -> Type) a where Source #

In the StIdle protocol state, the server does not have agency and can choose to send a request next, or a find intersection message.

Constructors

SendMsgRequestNext

Send the MsgRequestNext, with handlers for the replies.

The handlers for this message are more complicated than most RPCs because the server can either send us a reply immediately or it can send us a MsgAwaitReply to indicate that the server itself has to block for a state change before it can send us the reply.

In the waiting case, the client gets the chance to take a local action.

Fields

  • :: forall (m :: Type -> Type) header point tip a. m ()

    promptly invoked when MsgAwaitReply is received

  • -> ClientStNext header point tip m a
     
  • -> ClientStIdle header point tip m a
     
SendMsgFindIntersect :: forall point header tip (m :: Type -> Type) a. [point] -> ClientStIntersect header point tip m a -> ClientStIdle header point tip m a

Send the MsgFindIntersect, with handlers for the replies.

SendMsgDone :: forall a header point tip (m :: Type -> Type). a -> ClientStIdle header point tip m a

The client decided to end the protocol.

data ClientStNext header point tip (m :: Type -> Type) a Source #

In the StNext protocol state, the client does not have agency and is waiting to receive either

  • a roll forward,
  • roll back message,

It must be prepared to handle any of these.

Constructors

ClientStNext 

Fields

data ClientStIntersect header point tip (m :: Type -> Type) a Source #

In the StIntersect protocol state, the client does not have agency and is waiting to receive:

  • an intersection improved,
  • unchanged message,
  • the termination message.

It must be prepared to handle any of these.

Constructors

ClientStIntersect 

Fields

Null chain sync client

chainSyncClientNull :: forall (m :: Type -> Type) header point tip a. MonadTimer m => ChainSyncClient header point tip m a Source #

A chain sync client which never sends any message.

Utilities

mapChainSyncClient :: forall header header' point point' tip tip' (m :: Type -> Type) a. Functor m => (point -> point') -> (point' -> point) -> (header' -> header) -> (tip' -> tip) -> ChainSyncClient header point tip m a -> ChainSyncClient header' point' tip' m a Source #

Transform a ChainSyncClient by mapping over the tx header and the chain tip values.

Note the direction of the individual mapping functions corresponds to whether the types are used as protocol inputs or outputs (or both, as is the case for points).