Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- newtype ChainSyncClient header point tip (m :: Type -> Type) a = ChainSyncClient {
- runChainSyncClient :: m (ClientStIdle header point tip m a)
- data ClientStIdle header point tip (m :: Type -> Type) a where
- SendMsgRequestNext :: forall (m :: Type -> Type) header point tip a. m () -> 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
- SendMsgDone :: forall a header point tip (m :: Type -> Type). a -> ClientStIdle header point tip m a
- data ClientStNext header point tip (m :: Type -> Type) a = ClientStNext {
- recvMsgRollForward :: header -> tip -> ChainSyncClient header point tip m a
- recvMsgRollBackward :: point -> tip -> ChainSyncClient header point tip m a
- data ClientStIntersect header point tip (m :: Type -> Type) a = ClientStIntersect {
- recvMsgIntersectFound :: point -> tip -> ChainSyncClient header point tip m a
- recvMsgIntersectNotFound :: tip -> ChainSyncClient header point tip m a
- chainSyncClientPeer :: forall header point tip (m :: Type -> Type) a. Monad m => ChainSyncClient header point tip m a -> Client (ChainSync header point tip) 'NonPipelined ('StIdle :: ChainSync header point tip) m a
- 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
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
.
ChainSyncClient | |
|
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.
SendMsgRequestNext | Send the 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
In the waiting case, the client gets the chance to take a local action. |
| |
SendMsgFindIntersect :: forall point header tip (m :: Type -> Type) a. [point] -> ClientStIntersect header point tip m a -> ClientStIdle header point tip m a | Send the |
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.
ClientStNext | |
|
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.
ClientStIntersect | |
|
Execution as a typed protocol
chainSyncClientPeer :: forall header point tip (m :: Type -> Type) a. Monad m => ChainSyncClient header point tip m a -> Client (ChainSync header point tip) 'NonPipelined ('StIdle :: ChainSync header point tip) m a Source #
Interpret a ChainSyncClient
action sequence as a Peer
on the client
side of the ChainSyncProtocol
.
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).