@@ -19,12 +19,12 @@ import Data.Map.Strict as Map
19
19
import Hydra.HeadLogic (
20
20
Input (NetworkInput ),
21
21
)
22
- import Hydra.HeadLogic.Outcome (Outcome (Continue ), StateChanged (.. ))
22
+ import Hydra.HeadLogic.Outcome (Outcome (.. ), StateChanged (.. ))
23
23
import Hydra.Logging.Messages (HydraLog (.. ))
24
24
import Hydra.Network (PortNumber )
25
25
import Hydra.Network.Message (Message (ReqTx ), NetworkEvent (.. ))
26
26
import Hydra.Node (HydraNodeLog (.. ))
27
- import Hydra.Tx (IsTx (TxIdType ), Snapshot (confirmed ), txId )
27
+ import Hydra.Tx (IsTx (TxIdType ), Snapshot (.. ), txId )
28
28
import System.Metrics.Prometheus.Http.Scrape (serveMetrics )
29
29
import System.Metrics.Prometheus.Metric (Metric (CounterMetric , HistogramMetric ))
30
30
import System.Metrics.Prometheus.Metric.Counter (add , inc )
@@ -94,16 +94,19 @@ monitor transactionsMap metricsMap = \case
94
94
-- transactions after some timeout expires
95
95
atomically $ modifyTVar' transactionsMap (Map. insert (txId tx) t)
96
96
tick " hydra_head_requested_tx"
97
- (Node (LogicOutcome _ (Continue [SnapshotConfirmed _ snapshot _] _))) -> do
98
- t <- getMonotonicTime
99
- forM_ (confirmed snapshot) $ \ tx -> do
100
- txsStartTime <- readTVarIO transactionsMap
101
- case Map. lookup (txId tx) txsStartTime of
102
- Just start -> do
103
- atomically $ modifyTVar' transactionsMap $ Map. delete (txId tx)
104
- histo " hydra_head_tx_confirmation_time_ms" (diffTime t start)
105
- Nothing -> pure ()
106
- tickN " hydra_head_confirmed_tx" (length $ confirmed snapshot)
97
+ (Node LogicOutcome {outcome = Continue {stateChanges}}) -> do
98
+ forM_ stateChanges $ \ case
99
+ SnapshotConfirmed {snapshot = Snapshot {confirmed}} -> do
100
+ tickN " hydra_head_confirmed_tx" (length confirmed)
101
+ forM_ confirmed $ \ tx -> do
102
+ t <- getMonotonicTime
103
+ txsStartTime <- readTVarIO transactionsMap
104
+ case Map. lookup (txId tx) txsStartTime of
105
+ Just start -> do
106
+ atomically $ modifyTVar' transactionsMap $ Map. delete (txId tx)
107
+ histo " hydra_head_tx_confirmation_time_ms" (diffTime t start)
108
+ Nothing -> pure ()
109
+ _ -> pure ()
107
110
(Node (EndInput _ _)) ->
108
111
tick " hydra_head_inputs"
109
112
_ -> pure ()
0 commit comments