Skip to content

Commit

Permalink
Merge #1688
Browse files Browse the repository at this point in the history
1688: Trace transaction requests and replies in txSubmissionOutbound r=intricate a=intricate

Related to IntersectMBO/cardano-node#527.

More specifically, see IntersectMBO/cardano-node#584 (review).

Co-authored-by: Luke Nadur <[email protected]>
  • Loading branch information
iohk-bors[bot] and intricate authored Feb 26, 2020
2 parents b3f7bdd + f12e7c2 commit ba0117e
Showing 1 changed file with 15 additions and 3 deletions.
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'

0 comments on commit ba0117e

Please sign in to comment.