getValidatorBehaviorMetrics() gets metrics for validator behavior in this block
(address crypto.AddressI, qc *lib.QuorumCertificate)
| 678 | |
| 679 | // getValidatorBehaviorMetrics() gets metrics for validator behavior in this block |
| 680 | func (c *Controller) getValidatorBehaviorMetrics(address crypto.AddressI, qc *lib.QuorumCertificate) (isProducer bool, nonSigners map[string]uint64, doubleSigners []crypto.AddressI) { |
| 681 | nonSigners = make(map[string]uint64) |
| 682 | // 1. Track block producer |
| 683 | if proposerPubKey, err := crypto.NewPublicKeyFromBytes(qc.ProposerKey); err == nil { |
| 684 | isProducer = proposerPubKey.Address().Equals(address) |
| 685 | } |
| 686 | |
| 687 | // 2. Track non-signers - only if we have the validator set for this chain |
| 688 | if ns, err := c.FSM.GetNonSigners(); err == nil { |
| 689 | for _, n := range ns { |
| 690 | nonSigners[lib.BytesToString(n.Address)] = n.Counter |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | // 3. Track double signers (if evidence is available in the QC results) |
| 695 | // TODO this call is really inefficient - we need to segment double signers by block or address |
| 696 | if doubleSigner, err := c.FSM.GetDoubleSigners(); err == nil { |
| 697 | // for each double signer |
| 698 | for _, ds := range doubleSigner { |
| 699 | // for each height |
| 700 | for _, height := range ds.Heights { |
| 701 | // if double signed on the last height |
| 702 | if height == qc.Header.Height { |
| 703 | // update list |
| 704 | doubleSigners = append(doubleSigners, crypto.NewAddress(ds.Id)) |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | return |
| 710 | } |
| 711 | |
| 712 | // debugDumpHeaderDiff() logs the differences between the candidate and the constructed |
| 713 | func (c *Controller) debugDumpHeaderDiff(candidate, compare *lib.BlockHeader) { |
no test coverage detected