Safe Haskell | Safe-Inferred |
---|---|
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 a =
LocalTxMonitorClient
{
- runLocalTxMonitorClient :: m ( ClientStIdle txid tx slot m a)
-
data
ClientStIdle
txid tx slot m a
where
- SendMsgAcquire :: (slot -> m ( ClientStAcquired txid tx slot m a)) -> ClientStIdle txid tx slot m a
- SendMsgDone :: a -> ClientStIdle txid tx slot m a
-
data
ClientStAcquired
txid tx slot m a
where
- SendMsgNextTx :: ( Maybe tx -> m ( ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgHasTx :: txid -> ( Bool -> m ( ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgGetSizes :: ( MempoolSizeAndCapacity -> m ( ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgAwaitAcquire :: (slot -> m ( ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a
- SendMsgRelease :: m ( ClientStIdle txid tx slot m a) -> ClientStAcquired txid tx slot m a
- localTxMonitorClientPeer :: forall txid tx slot m a. Monad m => LocalTxMonitorClient txid tx slot m a -> Peer ( LocalTxMonitor txid tx slot) AsClient StIdle m a
Protocol type for the client
The protocol states from the point of view of the client.
newtype LocalTxMonitorClient txid tx slot m a Source #
A tx monitor client, on top of some effect
m
.
LocalTxMonitorClient | |
|
data ClientStIdle txid tx slot m 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 :: (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 :: a -> ClientStIdle txid tx slot m a |
The client decided to end the protocol |
data ClientStAcquired txid tx slot m 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 :: ( 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 :: 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 :: ( 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 :: (slot -> m ( ClientStAcquired txid tx slot m a)) -> ClientStAcquired txid tx slot m a |
Await for a new snapshot and acquire it. |
SendMsgRelease :: 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 a. Monad m => LocalTxMonitorClient txid tx slot m a -> Peer ( LocalTxMonitor txid tx slot) AsClient StIdle m a Source #
Interpret a
LocalTxMonitorClient
action sequence as a
Peer
on the
client-side of the
LocalTxMonitor
protocol.