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 a =
ChainSyncClient
{
- runChainSyncClient :: m ( ClientStIdle header point tip m a)
-
data
ClientStIdle
header point tip m a
where
- SendMsgRequestNext :: ClientStNext header point tip m a -> m ( ClientStNext header point tip m a) -> ClientStIdle header point tip m a
- SendMsgFindIntersect :: [point] -> ClientStIntersect header point tip m a -> ClientStIdle header point tip m a
- SendMsgDone :: a -> ClientStIdle header point tip m a
-
data
ClientStNext
header point tip m 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 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 a. Monad m => ChainSyncClient header point tip m a -> Peer ( ChainSync header point tip) AsClient StIdle m a
- chainSyncClientNull :: MonadTimer m => ChainSyncClient header point tip m a
- 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
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
.
ChainSyncClient | |
|
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.
SendMsgRequestNext :: ClientStNext header point tip m a -> m ( ClientStNext header point tip m a) -> ClientStIdle header point tip m a |
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 :: [point] -> ClientStIntersect header point tip m a -> ClientStIdle header point tip m a |
Send the
|
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.
ClientStNext | |
|
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.
ClientStIntersect | |
|
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).