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

Trace transaction requests and replies in txSubmissionOutbound #1688

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions ouroboros-network/src/Ouroboros/Network/TxSubmission/Outbound.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Control.Monad (when, unless)
import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadThrow
import Control.Exception (Exception(..), assert)
import Control.Tracer (Tracer)
import Control.Tracer (Tracer, traceWith)

import Ouroboros.Network.Protocol.TxSubmission.Client

Expand Down Expand Up @@ -69,7 +69,13 @@ data MempoolSnapshot txid tx idx =
mempoolLookupTx :: idx -> Maybe tx
}

data TraceTxSubmissionOutbound txid tx = TraceTxSubmissionOutbound --TODO
data TraceTxSubmissionOutbound txid tx
= TraceTxSubmissionOutboundRecvMsgRequestTxs
[txid]
-- ^ The IDs of the transactions requested.
| TraceTxSubmissionOutboundSendMsgReplyTxs
[tx]
-- ^ The transactions to be sent in the response.
deriving Show

data TxSubmissionProtocolError =
Expand Down Expand Up @@ -112,7 +118,7 @@ txSubmissionOutbound
-> Word16 -- ^ Maximum number of unacknowledged txids allowed
-> TxSubmissionMempoolReader txid tx idx m
-> TxSubmissionClient txid tx m void
txSubmissionOutbound _tracer maxUnacked TxSubmissionMempoolReader{..} =
txSubmissionOutbound tracer maxUnacked TxSubmissionMempoolReader{..} =
TxSubmissionClient (pure (client Seq.empty Map.empty mempoolZeroIdx))
where
client :: StrictSeq txid -> Map txid idx -> idx -> ClientStIdle txid tx m void
Expand Down Expand Up @@ -203,6 +209,9 @@ txSubmissionOutbound _tracer maxUnacked TxSubmissionMempoolReader{..} =
recvMsgRequestTxs :: [txid]
-> m (ClientStTxs txid tx m void)
recvMsgRequestTxs txids = do
-- Trace the IDs of the transactions requested.
traceWith tracer (TraceTxSubmissionOutboundRecvMsgRequestTxs txids)

MempoolSnapshot{mempoolLookupTx} <- atomically mempoolGetSnapshot

let txidxs = [ Map.lookup txid unackedMap | txid <- txids ]
Expand All @@ -218,4 +227,7 @@ txSubmissionOutbound _tracer maxUnacked TxSubmissionMempoolReader{..} =
!unackedMap' = foldl' (flip Map.delete) unackedMap txids
client' = client unackedSeq unackedMap' lastIdx

-- Trace the transactions to be sent in the response.
traceWith tracer (TraceTxSubmissionOutboundSendMsgReplyTxs txs)

return $ SendMsgReplyTxs txs client'