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.

94 lines
2.8 KiB

  1. package types
  2. import (
  3. // for registering TMEventData as events.EventData
  4. "github.com/tendermint/go-events"
  5. "github.com/tendermint/go-wire"
  6. )
  7. // Functions to generate eventId strings
  8. // Reserved
  9. func EventStringBond() string { return "Bond" }
  10. func EventStringUnbond() string { return "Unbond" }
  11. func EventStringRebond() string { return "Rebond" }
  12. func EventStringDupeout() string { return "Dupeout" }
  13. func EventStringFork() string { return "Fork" }
  14. func EventStringNewBlock() string { return "NewBlock" }
  15. func EventStringNewRound() string { return "NewRound" }
  16. func EventStringNewRoundStep() string { return "NewRoundStep" }
  17. func EventStringTimeoutPropose() string { return "TimeoutPropose" }
  18. func EventStringCompleteProposal() string { return "CompleteProposal" }
  19. func EventStringPolka() string { return "Polka" }
  20. func EventStringUnlock() string { return "Unlock" }
  21. func EventStringLock() string { return "Lock" }
  22. func EventStringRelock() string { return "Relock" }
  23. func EventStringTimeoutWait() string { return "TimeoutWait" }
  24. func EventStringVote() string { return "Vote" }
  25. //----------------------------------------
  26. // implements events.EventData
  27. type TMEventData interface {
  28. events.EventData
  29. // AssertIsTMEventData()
  30. }
  31. const (
  32. EventDataTypeNewBlock = byte(0x01)
  33. EventDataTypeFork = byte(0x02)
  34. EventDataTypeTx = byte(0x03)
  35. EventDataTypeRoundState = byte(0x11)
  36. EventDataTypeVote = byte(0x12)
  37. )
  38. var _ = wire.RegisterInterface(
  39. struct{ TMEventData }{},
  40. wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock},
  41. // wire.ConcreteType{EventDataFork{}, EventDataTypeFork },
  42. wire.ConcreteType{EventDataTx{}, EventDataTypeTx},
  43. wire.ConcreteType{EventDataRoundState{}, EventDataTypeRoundState},
  44. wire.ConcreteType{EventDataVote{}, EventDataTypeVote},
  45. )
  46. // Most event messages are basic types (a block, a transaction)
  47. // but some (an input to a call tx or a receive) are more exotic
  48. type EventDataNewBlock struct {
  49. // we drop block data but keep the form the same
  50. Block *BlockHeader `json:"block"`
  51. }
  52. type BlockHeader struct {
  53. Header *Header `json:"header"`
  54. }
  55. // All txs fire EventDataTx
  56. type EventDataTx struct {
  57. Tx Tx `json:"tx"`
  58. Result []byte `json:"result"`
  59. Log string `json:"log"`
  60. Error string `json:"error"`
  61. }
  62. // NOTE: This goes into the replay WAL
  63. type EventDataRoundState struct {
  64. Height int `json:"height"`
  65. Round int `json:"round"`
  66. Step string `json:"step"`
  67. // private, not exposed to websockets
  68. RoundState interface{} `json:"-"`
  69. }
  70. type EventDataVote struct {
  71. Index int
  72. Address []byte
  73. Vote *Vote
  74. }
  75. func (_ EventDataNewBlock) AssertIsTMEventData() {}
  76. func (_ EventDataTx) AssertIsTMEventData() {}
  77. func (_ EventDataRoundState) AssertIsTMEventData() {}
  78. func (_ EventDataVote) AssertIsTMEventData() {}