@@ -29,13 +29,12 @@ 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.Concurrent.STM.TVar (readTVar , registerDelay )
33
32
import Control.Monad.Class.MonadAsync (link )
34
- import Control.Monad.STM (STM , atomically , check , retry )
33
+ import Control.Monad.STM (atomically , retry )
35
34
import "contra-tracer" Control.Tracer (Tracer , traceWith )
36
35
import Data.Aeson (Value (Number , String ), toJSON , (.=) )
37
36
import Data.Text as Text
38
- import GHC.Conc (unsafeIOToSTM )
37
+ import GHC.Conc (labelThread , myThreadId , unsafeIOToSTM )
39
38
40
39
startLedgerMetricsTracer
41
40
:: forall blk
@@ -53,7 +52,9 @@ startLedgerMetricsTracer tr everyNThSlot nodeKernelData = do
53
52
link as
54
53
where
55
54
ledgerMetricsThread :: IO ()
56
- ledgerMetricsThread = go 1 SNothing
55
+ ledgerMetricsThread = do
56
+ myThreadId >>= flip labelThread " Peer Tracer"
57
+ go 1 SNothing
57
58
where
58
59
go :: Int -> StrictMaybe SlotNo -> IO ()
59
60
go ! i ! prevSlot = do
@@ -74,16 +75,10 @@ startLedgerMetricsTracer tr everyNThSlot nodeKernelData = do
74
75
case mSlot of
75
76
CurrentSlot s' | SJust s' /= prev -> return s'
76
77
_ -> do
77
- delaySTM $ 5 * 1000 -- 5 milliseconds
78
+ unsafeIOToSTM ( threadDelay $ 1 * 1000 )
78
79
retry
79
80
) nodeKernelData
80
81
81
- -- STM action that completes after a given delay (in microseconds)
82
- delaySTM :: Int -> STM ()
83
- delaySTM micros = do
84
- tvar <- unsafeIOToSTM (registerDelay micros) -- gives you a TVar Bool
85
- readTVar tvar >>= check
86
-
87
82
data LedgerMetrics =
88
83
LedgerMetrics {
89
84
tsSlotNo :: SlotNo
0 commit comments