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.

64 lines
1.8 KiB

7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
7 years ago
  1. # Subscribing to events via Websocket
  2. Tendermint emits different events, to which you can subscribe via
  3. [Websocket](https://en.wikipedia.org/wiki/WebSocket). This can be useful
  4. for third-party applications (for analysys) or inspecting state.
  5. [List of events](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants)
  6. You can subscribe to any of the events above by calling `subscribe` RPC
  7. method via Websocket.
  8. ```
  9. {
  10. "jsonrpc": "2.0",
  11. "method": "subscribe",
  12. "id": "0",
  13. "params": {
  14. "query": "tm.event='NewBlock'"
  15. }
  16. }
  17. ```
  18. Check out [API docs](https://tendermint.com/rpc/) for
  19. more information on query syntax and other options.
  20. You can also use tags, given you had included them into DeliverTx
  21. response, to query transaction results. See [Indexing
  22. transactions](./indexing-transactions.md) for details.
  23. ### ValidatorSetUpdates
  24. When validator set changes, ValidatorSetUpdates event is published. The
  25. event carries a list of pubkey/power pairs. The list is the same
  26. Tendermint receives from ABCI application (see [EndBlock
  27. section](../spec/abci/abci.md#endblock) in
  28. the ABCI spec).
  29. Response:
  30. ```
  31. {
  32. "jsonrpc": "2.0",
  33. "id": "0#event",
  34. "result": {
  35. "query": "tm.event='ValidatorSetUpdates'",
  36. "data": {
  37. "type": "tendermint/event/ValidatorSetUpdates",
  38. "value": {
  39. "validator_updates": [
  40. {
  41. "address": "09EAD022FD25DE3A02E64B0FE9610B1417183EE4",
  42. "pub_key": {
  43. "type": "tendermint/PubKeyEd25519",
  44. "value": "ww0z4WaZ0Xg+YI10w43wTWbBmM3dpVza4mmSQYsd0ck="
  45. },
  46. "voting_power": "10",
  47. "accum": "0"
  48. }
  49. ]
  50. }
  51. }
  52. }
  53. }
  54. ```