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.

68 lines
1.8 KiB

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