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.

90 lines
2.7 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. Block *Block `json:"block"`
  50. }
  51. // All txs fire EventDataTx
  52. type EventDataTx struct {
  53. Tx Tx `json:"tx"`
  54. Result []byte `json:"result"`
  55. Log string `json:"log"`
  56. Error string `json:"error"`
  57. }
  58. // NOTE: This goes into the replay WAL
  59. type EventDataRoundState struct {
  60. Height int `json:"height"`
  61. Round int `json:"round"`
  62. Step string `json:"step"`
  63. // private, not exposed to websockets
  64. RoundState interface{} `json:"-"`
  65. }
  66. type EventDataVote struct {
  67. Index int
  68. Address []byte
  69. Vote *Vote
  70. }
  71. func (_ EventDataNewBlock) AssertIsTMEventData() {}
  72. func (_ EventDataTx) AssertIsTMEventData() {}
  73. func (_ EventDataRoundState) AssertIsTMEventData() {}
  74. func (_ EventDataVote) AssertIsTMEventData() {}