Skip to content

Commit

Permalink
Fix empty prevote latency metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Aug 18, 2023
1 parent 4b4be31 commit 446fd45
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,10 @@ func (cs *State) RecordMetrics(height int64, block *types.Block) {
for roundId := 0; int32(roundId) <= roundState.ValidRound; roundId++ {
preVotes := roundState.Votes.Prevotes(int32(roundId))
pl := preVotes.List()
if pl == nil || len(pl) == 0 {
cs.logger.Info("no prevotes to emit latency metrics for", "height", height, "round", roundId)
continue
}
sort.Slice(pl, func(i, j int) bool {
return pl[i].Timestamp.Before(pl[j].Timestamp)
})
Expand Down

0 comments on commit 446fd45

Please sign in to comment.