Skip to content

Commit

Permalink
do no crash process
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Sep 15, 2024
1 parent 37da7b2 commit 20b8552
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions protocol/monitoring/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,17 @@ func (al *Alerting) ProvidersAlerts(healthResults *HealthResults) {
for provider, data := range healthResults.ProviderData {
specId := provider.SpecId
if al.allowedTimeGapVsReference > 0 {
latestBlock := healthResults.LatestBlocks[specId]
latestBlock, ok := healthResults.LatestBlocks[specId]
if !ok {
utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId})
return
}
if latestBlock > data.Block {
gap := latestBlock - data.Block
specHealthResult, ok := healthResults.Specs[specId]
if !ok {
utils.LavaFormatFatal("Invalid specid - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId})
utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId})
return
}
timeGap := time.Duration(gap*specHealthResult.AverageBlockTime) * time.Millisecond
if timeGap > al.allowedTimeGapVsReference {
Expand Down

0 comments on commit 20b8552

Please sign in to comment.