ouroboros-network-protocols-0.8.1.0: Ouroboros Network Protocols
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Network.Protocol.LocalTxMonitor.Client

Description

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

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.

Constructors

LocalTxMonitorClient 

Fields

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.

Constructors

SendMsgAcquire ∷ (slot → m (ClientStAcquired txid tx slot m a)) → ClientStIdle txid tx slot m a

Send the MsgAcquire, with handlers for the replies.

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.

Constructors

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. MsgNextTx requests the next transaction from the current list. This must be a transaction that was not previously sent to the client for this particular snapshot.

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. False simply means that it is no longer in the mempool.

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 ∷ ∀ 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.