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.

27 lines
823 B

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