Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A view of the chain synchronisation protocol from the point of view of the server.
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 ChainSyncServer header point tip m a = ChainSyncServer {
- runChainSyncServer ∷ m (ServerStIdle header point tip m a)
- data ServerStIdle header point tip m a = ServerStIdle {
- recvMsgRequestNext ∷ m (Either (ServerStNext header point tip m a) (m (ServerStNext header point tip m a)))
- recvMsgFindIntersect ∷ [point] → m (ServerStIntersect header point tip m a)
- recvMsgDoneClient ∷ m a
- data ServerStNext header point tip m a where
- SendMsgRollForward ∷ header → tip → ChainSyncServer header point tip m a → ServerStNext header point tip m a
- SendMsgRollBackward ∷ point → tip → ChainSyncServer header point tip m a → ServerStNext header point tip m a
- data ServerStIntersect header point tip m a where
- SendMsgIntersectFound ∷ point → tip → ChainSyncServer header point tip m a → ServerStIntersect header point tip m a
- SendMsgIntersectNotFound ∷ tip → ChainSyncServer header point tip m a → ServerStIntersect header point tip m a
- chainSyncServerPeer ∷ ∀ header point tip m a. Monad m ⇒ ChainSyncServer header point tip m a → Peer (ChainSync header point tip) AsServer StIdle m a
Protocol type for the server
The protocol states from the point of view of the server.
newtype ChainSyncServer header point tip m a Source #
A chain sync protocol server, on top of some effect m
.
ChainSyncServer | |
|
data ServerStIdle header point tip m a Source #
In the StIdle
protocol state, the server does not have agency. Instead
it is waiting for:
- a next update request
- a find intersection request
- a termination messge
It must be prepared to handle either.
ServerStIdle | |
|
data ServerStNext header point tip m a where Source #
In the StNext
protocol state, the server has agency and must send either:
- a roll forward
- a roll back message
- a termination message
SendMsgRollForward ∷ header → tip → ChainSyncServer header point tip m a → ServerStNext header point tip m a | |
SendMsgRollBackward ∷ point → tip → ChainSyncServer header point tip m a → ServerStNext header point tip m a |
data ServerStIntersect header point tip m a where Source #
In the StIntersect
protocol state, the server has agency and must send
either:
- an intersection improved,
- unchanged message,
- termination message
SendMsgIntersectFound ∷ point → tip → ChainSyncServer header point tip m a → ServerStIntersect header point tip m a | |
SendMsgIntersectNotFound ∷ tip → ChainSyncServer header point tip m a → ServerStIntersect header point tip m a |
Execution as a typed protocol
chainSyncServerPeer ∷ ∀ header point tip m a. Monad m ⇒ ChainSyncServer header point tip m a → Peer (ChainSync header point tip) AsServer StIdle m a Source #
Interpret a ChainSyncServer
action sequence as a Peer
on the server
side of the ChainSyncProtocol
.