Skip to content

Commit

Permalink
Improved tracing when ledger peers is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
karknu authored and coot committed Jan 28, 2021
1 parent 26b2f0c commit c94cf77
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -23,6 +23,7 @@ module Ouroboros.Network.PeerSelection.LedgerPeers (
) where


import Control.Monad (when)
import Control.Monad.Class.MonadAsync
import Control.Monad.Class.MonadSTM.Strict
import Control.Monad.Class.MonadTime
Expand Down Expand Up @@ -70,6 +71,8 @@ data TraceLedgerPeers =
| FetchingNewLedgerState !Int
-- ^ Trace for fetching a new list of peers from the ledger. Int is the number of peers
-- returned.
| DisabledLedgerPeers
-- ^ Trace for when getting peers from the ledger is disabled, that is DontUseLedger.
| WaitingOnRequest
| RequestForPeers !NumberOfPeers
| ReusingLedgerState !Int !DiffTime
Expand All @@ -96,6 +99,7 @@ instance Show TraceLedgerPeers where
cnt
(show age)
show FallingBackToBootstrapPeers = "Falling back to bootstrap peers"
show DisabledLedgerPeers = "LedgerPeers is disabled"

-- | A relay can have either an IP address and a port number or
-- a domain with a port number
Expand Down Expand Up @@ -208,7 +212,7 @@ runLedgerPeers inRng tracer useLedgerAfter LedgerPeersConsensusInterface{..} doR
then
case useLedgerAfter of
DontUseLedger -> do
traceWith tracer $ FetchingNewLedgerState 0
traceWith tracer DisabledLedgerPeers
return (Map.empty, now)
UseLedgerAfter slot -> do
peers_m <- atomically $ lpGetPeers slot
Expand All @@ -222,7 +226,8 @@ runLedgerPeers inRng tracer useLedgerAfter LedgerPeersConsensusInterface{..} doR

if Map.null peerMap'
then do
traceWith tracer FallingBackToBootstrapPeers
when (isLedgerPeersEnabled useLedgerAfter) $
traceWith tracer FallingBackToBootstrapPeers
atomically $ putRsp Nothing
go rng ts peerMap'
else do
Expand Down

0 comments on commit c94cf77

Please sign in to comment.