ouroboros-network-0.1.0.1: A networking layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Network.Protocol.ChainSync.Client

Description

A view of the chain synchronisation protocol from the point of view of the client.

This provides a view that uses less complex types and should be easier to use than the underlying typed protocol itself.

For execution, a conversion into the typed protocol is provided.

Synopsis

Protocol type for the client

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

newtype ChainSyncClient header point tip m 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 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 :: ClientStNext header point tip m a -> m ( ClientStNext header point tip m a) -> ClientStIdle header point tip m a

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.

SendMsgFindIntersect :: [point] -> ClientStIntersect header point tip m a -> ClientStIdle header point tip m a

Send the MsgFindIntersect , with handlers for the replies.

SendMsgDone :: a -> ClientStIdle header point tip m a

The client decided to end the protocol.

data ClientStNext header point tip m 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 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

Execution as a typed protocol

chainSyncClientPeer :: forall header point tip m a. Monad m => ChainSyncClient header point tip m a -> Peer ( ChainSync header point tip) AsClient StIdle m a Source #

Interpret a ChainSyncClient action sequence as a Peer on the client side of the ChainSyncProtocol .

Null chain sync client

chainSyncClientNull :: MonadTimer m => ChainSyncClient header point tip m a Source #

Deprecated: Use Ouroboros.Network.NodeToClient.chainSyncPeerNull

A chain sync client which never sends any message.

Utilities

mapChainSyncClient :: forall header header' point point' tip tip' m 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).