@@ -29,7 +29,7 @@ data ForgingStats
29
29
fsNodeCannotForgeNum :: ! Int
30
30
, fsNodeIsLeaderNum :: ! Int
31
31
, fsBlocksForgedNum :: ! Int
32
- , fsLastSlot :: ! Int
32
+ , fsLastSlot :: ! Int -- Internal value, to track last slot.
33
33
, fsSlotsMissedNum :: ! Int
34
34
}
35
35
@@ -73,8 +73,6 @@ instance MetaTrace ForgingStats where
73
73
" How many blocks did this node forge?" )
74
74
,(" slotsMissed" ,
75
75
" How many slots did this node miss?" )
76
- ,(" lastSlot" ,
77
- " " )
78
76
]
79
77
80
78
allNamespaces = [Namespace [] [" ForgingStats" ]]
@@ -102,21 +100,24 @@ calculateForgingStats :: MonadIO m
102
100
-> m ForgingStats
103
101
calculateForgingStats stats _context
104
102
(Left TraceNodeCannotForge {}) =
105
- pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
103
+ pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
106
104
calculateForgingStats stats _context
107
- (Left TraceNodeIsLeader {}) =
108
- pure $ stats { fsNodeIsLeaderNum = fsNodeIsLeaderNum stats + 1 }
105
+ (Left (TraceNodeIsLeader (SlotNo slot))) =
106
+ pure $ stats
107
+ { fsNodeIsLeaderNum = fsNodeIsLeaderNum stats + 1 , fsLastSlot = fromIntegral slot }
109
108
calculateForgingStats stats _context
110
109
(Left TraceForgedBlock {}) =
111
- pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
110
+ pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
112
111
calculateForgingStats stats _context
113
112
(Left (TraceNodeNotLeader (SlotNo slot'))) =
113
+ -- Node is not a leader again: The number of blocks forged by
114
+ -- this node should now be equal to the number of slots when
115
+ -- this node was a leader.
114
116
let slot = fromIntegral slot'
115
117
in if fsLastSlot stats == 0 || succ (fsLastSlot stats) == slot
116
118
then pure $ stats { fsLastSlot = slot }
117
119
else
118
- let missed = ( slot - fsLastSlot stats)
120
+ let missed = slot - fsLastSlot stats
119
121
in pure $ stats { fsLastSlot = slot
120
- , fsSlotsMissedNum = fsSlotsMissedNum stats + missed}
121
-
122
+ , fsSlotsMissedNum = fsSlotsMissedNum stats + missed }
122
123
calculateForgingStats stats _context _message = pure stats
0 commit comments