Skip to content

Commit

Permalink
reset quorums
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Apr 26, 2024
1 parent d744711 commit c144678
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (g *Metrics) collectOnchainMetrics() {
}
quorumIds := eth.BitmapToQuorumIds(bitmaps[0])
if len(quorumIds) == 0 {
g.ResetQuorumMetrics(blockNum)
g.logger.Warn("This node is currently not in any quorum", "blockNumber", blockNum, "operatorId", g.operatorId.Hex())
continue
}
Expand Down Expand Up @@ -236,16 +237,20 @@ func (g *Metrics) collectOnchainMetrics() {
}
}
// Check if operator deregistered for an existing quorum, set the stake share and rank to 0
for q := range g.allQuorumCache {
// If this quorum was deregistered then set the stake share and rank to 0
if !g.allQuorumCache[q] {
g.RegisteredQuorumsStakeShare.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.RegisteredQuorumsRank.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.logger.Info("Current operator deregistration onchain", "operatorId", g.operatorId.Hex(), "blockNumber", blockNum, "quorumId", q)
} else {
// Reset the cache to false for all quorum for next cycle
g.allQuorumCache[q] = false
}
g.ResetQuorumMetrics(blockNum)
}
}

func (g *Metrics) ResetQuorumMetrics(blockNum uint32) {
// Check if operator deregistered for an existing quorum, set the stake share and rank to 0
for q := range g.allQuorumCache {
// If this quorum was deregistered then set the stake share and rank to 0
if !g.allQuorumCache[q] {
g.RegisteredQuorumsStakeShare.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.RegisteredQuorumsRank.WithLabelValues(fmt.Sprintf("%d", q)).Set(0)
g.logger.Info("Current operator deregistration onchain", "operatorId", g.operatorId.Hex(), "blockNumber", blockNum, "quorumId", q)
}
// Reset the cache to false for all quorum for next cycle
g.allQuorumCache[q] = false
}
}

0 comments on commit c144678

Please sign in to comment.