mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-13 10:41:30 +00:00
cs: check if cs.privValidator is nil (#4295)
before getting its address in recordMetrics Refs https://github.com/tendermint/tendermint/pull/4294#discussion_r364347586
This commit is contained in:
@@ -1486,10 +1486,14 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
|
||||
|
||||
for i, val := range cs.LastValidators.Validators {
|
||||
commitSig := block.LastCommit.Signatures[i]
|
||||
privValAddress := cs.privValidator.GetPubKey().Address()
|
||||
if cs.privValidator != nil && bytes.Equal(val.Address, privValAddress) {
|
||||
if commitSig.Absent() {
|
||||
missingValidators++
|
||||
missingValidatorsPower += val.VotingPower
|
||||
}
|
||||
|
||||
if cs.privValidator != nil && bytes.Equal(val.Address, cs.privValidator.GetPubKey().Address()) {
|
||||
label := []string{
|
||||
"validator_address", privValAddress.String(),
|
||||
"validator_address", val.Address.String(),
|
||||
}
|
||||
cs.metrics.ValidatorPower.With(label...).Set(float64(val.VotingPower))
|
||||
if commitSig.ForBlock() {
|
||||
@@ -1498,11 +1502,6 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
|
||||
cs.metrics.ValidatorMissedBlocks.With(label...).Add(float64(1))
|
||||
}
|
||||
}
|
||||
|
||||
if commitSig.Absent() {
|
||||
missingValidators++
|
||||
missingValidatorsPower += val.VotingPower
|
||||
}
|
||||
}
|
||||
}
|
||||
cs.metrics.MissingValidators.Set(float64(missingValidators))
|
||||
|
||||
Reference in New Issue
Block a user