You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
870 B

  1. package core
  2. import (
  3. "fmt"
  4. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  5. rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. // BroadcastEvidence broadcasts evidence of the misbehavior.
  9. // More: https://docs.tendermint.com/master/rpc/#/Evidence/broadcast_evidence
  10. func (env *Environment) BroadcastEvidence(
  11. ctx *rpctypes.Context,
  12. ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
  13. if ev == nil {
  14. return nil, fmt.Errorf("%w: no evidence was provided", ctypes.ErrInvalidRequest)
  15. }
  16. if err := ev.ValidateBasic(); err != nil {
  17. return nil, fmt.Errorf("evidence.ValidateBasic failed: %w", err)
  18. }
  19. if err := env.EvidencePool.AddEvidence(ev); err != nil {
  20. return nil, fmt.Errorf("failed to add evidence: %w", err)
  21. }
  22. return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil
  23. }