@@ -29,7 +29,7 @@ data ForgingStats
2929 fsNodeCannotForgeNum :: ! Int
3030 , fsNodeIsLeaderNum :: ! Int
3131 , fsBlocksForgedNum :: ! Int
32- , fsLastSlot :: ! Int
32+ , fsLastSlot :: ! Int -- Internal value, to track last slot.
3333 , fsSlotsMissedNum :: ! Int
3434 }
3535
@@ -73,8 +73,6 @@ instance MetaTrace ForgingStats where
7373 " How many blocks did this node forge?" )
7474 ,(" slotsMissed" ,
7575 " How many slots did this node miss?" )
76- ,(" lastSlot" ,
77- " " )
7876 ]
7977
8078 allNamespaces = [Namespace [] [" ForgingStats" ]]
@@ -102,21 +100,24 @@ calculateForgingStats :: MonadIO m
102100 -> m ForgingStats
103101calculateForgingStats stats _context
104102 (Left TraceNodeCannotForge {}) =
105- pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
103+ pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
106104calculateForgingStats 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 }
109108calculateForgingStats stats _context
110109 (Left TraceForgedBlock {}) =
111- pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
110+ pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
112111calculateForgingStats stats _context
113112 (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.
114116 let slot = fromIntegral slot'
115117 in if fsLastSlot stats == 0 || succ (fsLastSlot stats) == slot
116118 then pure $ stats { fsLastSlot = slot }
117119 else
118- let missed = ( slot - fsLastSlot stats)
120+ let missed = slot - fsLastSlot stats
119121 in pure $ stats { fsLastSlot = slot
120- , fsSlotsMissedNum = fsSlotsMissedNum stats + missed}
121-
122+ , fsSlotsMissedNum = fsSlotsMissedNum stats + missed }
122123calculateForgingStats stats _context _message = pure stats
0 commit comments