Browse Source

metrics: only increase last_signed_height if commitSig for block (#4283)

- follow up to #4263
- when a commit is nil, then it should be counted as a missed commit

Signed-off-by: Marko Baricevic marbar3778@yahoo.com
pull/4292/head
Marko 5 years ago
committed by Anton Kaliaev
parent
commit
d7f4ce30ca
2 changed files with 6 additions and 1 deletions
  1. +1
    -1
      consensus/state.go
  2. +5
    -0
      types/block.go

+ 1
- 1
consensus/state.go View File

@ -1492,7 +1492,7 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
"validator_address", privValAddress.String(),
}
cs.metrics.ValidatorPower.With(label...).Set(float64(val.VotingPower))
if !commitSig.Absent() {
if commitSig.ForBlock() {
cs.metrics.ValidatorLastSignedHeight.With(label...).Set(float64(height))
} else {
cs.metrics.ValidatorMissedBlocks.With(label...).Add(float64(1))


+ 5
- 0
types/block.go View File

@ -466,6 +466,11 @@ func NewCommitSigForBlock(signature []byte, valAddr Address, ts time.Time) Commi
}
}
// ForBlock returns true if CommitSig is for the block.
func (cs CommitSig) ForBlock() bool {
return cs.BlockIDFlag == BlockIDFlagCommit
}
// NewCommitSigAbsent returns new CommitSig with BlockIDFlagAbsent. Other
// fields are all empty.
func NewCommitSigAbsent() CommitSig {


Loading…
Cancel
Save