@@ -29,6 +29,7 @@ import qualified Ouroboros.Network.AnchoredFragment as AF
29
29
30
30
import Control.Concurrent (threadDelay )
31
31
import Control.Concurrent.Async (async )
32
+ import Control.Monad (when )
32
33
import Control.Monad.Class.MonadAsync (link )
33
34
import Control.Monad.STM (atomically , retry )
34
35
import "contra-tracer" Control.Tracer (Tracer , traceWith )
@@ -57,16 +58,16 @@ startLedgerMetricsTracer tr everyNThSlot nodeKernelData = do
57
58
go 1 SNothing
58
59
where
59
60
go :: Int -> StrictMaybe SlotNo -> IO ()
60
- go ! i ! prevSlot = do
61
+ go ! countdown ! prevSlot = do
61
62
! query <- waitForDifferentSlot prevSlot
62
63
threadDelay $ 700 * 1000
63
64
case query of
64
- SJust slot'
65
- | i `mod` everyNThSlot == 0 -> do
66
- traceLedgerMetrics nodeKernelData slot' tr
67
- go (i + 1 ) ( SJust slot')
68
- | otherwise -> go (i + 1 ) (SJust slot')
69
- SNothing -> go i prevSlot
65
+ SJust slot' -> do
66
+ let nextCountdown = if countdown <= 1 then everyNThSlot else countdown - 1
67
+ when (countdown == 1 ) $
68
+ traceLedgerMetrics nodeKernelData slot' tr
69
+ go nextCountdown (SJust slot')
70
+ SNothing -> go countdown prevSlot
70
71
71
72
waitForDifferentSlot :: StrictMaybe SlotNo -> IO (StrictMaybe SlotNo )
72
73
waitForDifferentSlot prev = do
0 commit comments