Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the tx mempool monitoring mini protocol in cardano-api #3706

Merged
merged 2 commits into from
Apr 5, 2022

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Mar 14, 2022

Resolves: #3698

@Jimbo4350 Jimbo4350 force-pushed the jordan/wireup-tx-mempool-monitoring branch 2 times, most recently from 3e0859d to 93fd249 Compare March 14, 2022 19:43
@Jimbo4350 Jimbo4350 force-pushed the jordan/wireup-tx-mempool-monitoring branch 2 times, most recently from b392380 to 4110200 Compare March 16, 2022 19:51
Implement TxIdInMode
This sets the stage to expose a user facing function to utilize the
local tx monitoring mini protocol
…nality

to utilize the local tx monitoring protocol which allows users to:
  Check if a transaction exists in the mempool
  Request the next tx in the mempool
  Request the current size and capacity of the mempool

Note: This is not exposed via cardano-cli as yet
@Jimbo4350 Jimbo4350 force-pushed the jordan/wireup-tx-mempool-monitoring branch from 4110200 to ac8f3b5 Compare March 30, 2022 13:32
-- | The mempool is modeled as an ordered list of transactions and thus, can
-- be traversed linearly. 'LocalTxMonitoringSendNextTx' 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.
Copy link
Contributor

@newhoggy newhoggy Mar 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there state associated with the connection that tracks where the current transaction in the list is?

Copy link
Contributor Author

@Jimbo4350 Jimbo4350 Mar 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only 3 things you can get:

data ServerStBusy (kind :: StBusyKind) txid tx slot m a where
  SendMsgReplyNextTx
    :: Maybe tx
    -> ServerStAcquired txid tx slot m a
    -> ServerStBusy NextTx txid tx slot m a

  SendMsgReplyHasTx
    :: Bool
    -> ServerStAcquired txid tx slot m a
    -> ServerStBusy HasTx txid tx slot m a

  SendMsgReplyGetSizes
    :: MempoolSizeAndCapacity
    -> ServerStAcquired txid tx slot m a
    -> ServerStBusy GetSizes txid tx slot 

The next tx, if a tx exists or the mempool size.

@@ -6,12 +6,17 @@
-- | Transactions in the context of a consensus mode, and other types used in
-- the transaction submission protocol.
--
module Cardano.Api.TxInMode (
module Cardano.Api.InMode (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation for the module rename?

Maybe the comment for the module needs adjustment too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we now have TxInMode and TxIdInMode. I figured it would make sense to drop the Tx because of this.

@newhoggy newhoggy self-requested a review April 5, 2022 12:56
@Jimbo4350
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 5, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit d47f85b into master Apr 5, 2022
@iohk-bors iohk-bors bot deleted the jordan/wireup-tx-mempool-monitoring branch April 5, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose local tx monitoring protocol in cardano-api
2 participants