Safe Haskell | None |
---|---|
Language | Haskell2010 |
A view of the transaction monitor protocol from the point of view of the client.
This provides simple access to the local mempool snapshots, to allow building more monitoring logic from the client side after submitting transactions.
For execution, localTxMonitorClientPeer
is provided for conversion
into the typed protocol.
Synopsis
- newtype LocalTxMonitorClient txid tx slot (m :: Type -> Type) a = LocalTxMonitorClient {
- runLocalTxMonitorClient :: m (ClientStIdle txid tx slot m a)
- data ClientStIdle txid tx slot (m :: Type -> Type) a where
- SendMsgAcquire :: forall slot (m :: Type -> Type) txid tx a. (slot -> m (ClientStAcquired txid tx slot m a)) -> ClientStIdle txid tx slot m a
- SendMsgDone :: forall a txid tx slot (m :: Type -> Type). a -> ClientStIdle txid tx slot m a
- data ClientStAcquired txid tx slot (m :: Type -> Type) a where
- SendMsgNextTx :: forall tx (m :: Type -> Type) txid slot a. (Maybe tx -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgHasTx :: forall txid (m :: Type -> Type) tx slot a. txid -> (Bool -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgGetSizes :: forall (m :: Type -> Type) txid tx slot a. (MempoolSizeAndCapacity -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgAwaitAcquire :: forall slot (m :: Type -> Type) txid tx a. (slot -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgRelease :: forall (m :: Type -> Type) txid tx slot a. m (ClientStIdle txid tx slot m a) -> ClientStAcquired txid tx slot m a
- localTxMonitorClientPeer :: forall txid tx slot (m :: Type -> Type) a. Monad m => LocalTxMonitorClient txid tx slot m a -> Client (LocalTxMonitor txid tx slot) 'NonPipelined ('StIdle :: LocalTxMonitor txid tx slot) m a
Protocol type for the client
The protocol states from the point of view of the client.
newtype LocalTxMonitorClient txid tx slot (m :: Type -> Type) a Source #
A tx monitor client, on top of some effect m
.
LocalTxMonitorClient | |
|
data ClientStIdle txid tx slot (m :: Type -> Type) a where Source #
In the StIdle
protocol state, the client has agency and can proceed to
acquire a mempool snapshot, or end the protocol.
SendMsgAcquire :: forall slot (m :: Type -> Type) txid tx a. (slot -> m (ClientStAcquired txid tx slot m a)) -> ClientStIdle txid tx slot m a | Send the This request cannot timeout and cannot fail, it'll acquire the latest mempool snapshot available on the server and hang on to it. This allows to run any subsequent queries against the same view of the mempool. The snapshot is acquired for a particular slot number which materializes the 'virtual block' under construction. |
SendMsgDone :: forall a txid tx slot (m :: Type -> Type). a -> ClientStIdle txid tx slot m a | The client decided to end the protocol |
data ClientStAcquired txid tx slot (m :: Type -> Type) a where Source #
In the StAcquired
protocol state, the client has agency and can query the
server against the acquired snapshot. Alternatively, it can also (re)acquire
a more recent snapshot.
SendMsgNextTx :: forall tx (m :: Type -> Type) txid slot a. (Maybe tx -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a | The mempool is modeled as an ordered list of transactions and thus, can
be traversed linearly. |
SendMsgHasTx :: forall txid (m :: Type -> Type) tx slot a. txid -> (Bool -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a | For some cases where clients do not wish to traverse the entire mempool
but look for a specific transaction, they can assess the presence of such
transaction directly. Note that, the absence of a transaction does not
imply anything about how the transaction was processed: it may have been
dropped, or inserted in a block. |
SendMsgGetSizes :: forall (m :: Type -> Type) txid tx slot a. (MempoolSizeAndCapacity -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a | Ask the server about the current mempool's capacity and sizes. This is fixed in a given snapshot. |
SendMsgAwaitAcquire :: forall slot (m :: Type -> Type) txid tx a. (slot -> m (ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a | Await for a new snapshot and acquire it. |
SendMsgRelease :: forall (m :: Type -> Type) txid tx slot a. m (ClientStIdle txid tx slot m a) -> ClientStAcquired txid tx slot m a | Release the acquired snapshot, in order to loop back to the idle state. |
Execution as a typed protocol
localTxMonitorClientPeer :: forall txid tx slot (m :: Type -> Type) a. Monad m => LocalTxMonitorClient txid tx slot m a -> Client (LocalTxMonitor txid tx slot) 'NonPipelined ('StIdle :: LocalTxMonitor txid tx slot) m a Source #
Interpret a LocalTxMonitorClient
action sequence as a Peer
on the
client-side of the LocalTxMonitor
protocol.