Skip to content

Commit

Permalink
Add peer to TraceKeepAliveClient
Browse files Browse the repository at this point in the history
  • Loading branch information
karknu committed Jul 1, 2020
1 parent 203d7b5 commit 22609f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -60,7 +60,7 @@ data Tracers' remotePeer localPeer blk f = Tracers
, mempoolTracer :: f (TraceEventMempool blk)
, forgeTracer :: f (TraceForgeEvent blk)
, blockchainTimeTracer :: f TraceBlockchainTimeEvent
, keepAliveClientTracer :: f TraceKeepAliveClient
, keepAliveClientTracer :: f (TraceKeepAliveClient remotePeer)

-- | Called on every slot with the possibly updated 'ForgeState'
--
Expand Down
12 changes: 7 additions & 5 deletions ouroboros-network/src/Ouroboros/Network/KeepAlive.hs
Expand Up @@ -28,9 +28,11 @@ import Ouroboros.Network.Protocol.KeepAlive.Server

newtype KeepAliveInterval = KeepAliveInterval { keepAliveInterval :: DiffTime }

data TraceKeepAliveClient =
AddSample DiffTime
deriving Show
data TraceKeepAliveClient peer =
AddSample peer DiffTime

instance Show peer => Show (TraceKeepAliveClient peer) where
show (AddSample peer rtt) = "AddSample " ++ show peer ++ show rtt

keepAliveClient
:: forall m peer.
Expand All @@ -39,7 +41,7 @@ keepAliveClient
, MonadTimer m
, Ord peer
)
=> Tracer m TraceKeepAliveClient
=> Tracer m (TraceKeepAliveClient peer)
-> peer
-> (StrictTVar m (M.Map peer PeerGSV))
-> KeepAliveInterval
Expand All @@ -60,7 +62,7 @@ keepAliveClient tracer peer dqCtx KeepAliveInterval { keepAliveInterval } startT
startTime_m <- atomically $ readTVar startTimeV
case startTime_m of
Just startTime -> do
traceWith tracer $ AddSample $ diffTime endTime startTime
traceWith tracer $ AddSample peer $ diffTime endTime startTime
let sample = fromSample startTime endTime payloadSize
atomically $ modifyTVar dqCtx $ \m ->
assert (peer `M.member` m) $
Expand Down

0 comments on commit 22609f2

Please sign in to comment.