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.

39 lines
1.2 KiB

  1. package core
  2. import (
  3. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  4. rpctypes "github.com/tendermint/tendermint/rpc/lib/types"
  5. "github.com/tendermint/tendermint/types"
  6. )
  7. // Broadcast evidence of the misbehavior.
  8. //
  9. // ```shell
  10. // curl 'localhost:26657/broadcast_evidence?evidence={amino-encoded DuplicateVoteEvidence}'
  11. // ```
  12. //
  13. // ```go
  14. // client := client.NewHTTP("tcp://0.0.0.0:26657", "/websocket")
  15. // err := client.Start()
  16. // if err != nil {
  17. // // handle error
  18. // }
  19. // defer client.Stop()
  20. // res, err := client.BroadcastEvidence(&types.DuplicateVoteEvidence{PubKey: ev.PubKey, VoteA: ev.VoteA, VoteB: ev.VoteB})
  21. // ```
  22. //
  23. // > The above command returns JSON structured like this:
  24. //
  25. // ```json
  26. // ```
  27. //
  28. // | Parameter | Type | Default | Required | Description |
  29. // |-----------+----------------+---------+----------+-----------------------------|
  30. // | evidence | types.Evidence | nil | true | Amino-encoded JSON evidence |
  31. func BroadcastEvidence(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
  32. err := evidencePool.AddEvidence(ev)
  33. if err != nil {
  34. return nil, err
  35. }
  36. return &ctypes.ResultBroadcastEvidence{Hash: ev.Hash()}, nil
  37. }