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.

99 lines
3.1 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 EventStringNewBlockHeader() string { return "NewBlockHeader" }
  16. func EventStringNewRound() string { return "NewRound" }
  17. func EventStringNewRoundStep() string { return "NewRoundStep" }
  18. func EventStringTimeoutPropose() string { return "TimeoutPropose" }
  19. func EventStringCompleteProposal() string { return "CompleteProposal" }
  20. func EventStringPolka() string { return "Polka" }
  21. func EventStringUnlock() string { return "Unlock" }
  22. func EventStringLock() string { return "Lock" }
  23. func EventStringRelock() string { return "Relock" }
  24. func EventStringTimeoutWait() string { return "TimeoutWait" }
  25. func EventStringVote() string { return "Vote" }
  26. //----------------------------------------
  27. // implements events.EventData
  28. type TMEventData interface {
  29. events.EventData
  30. // AssertIsTMEventData()
  31. }
  32. const (
  33. EventDataTypeNewBlock = byte(0x01)
  34. EventDataTypeFork = byte(0x02)
  35. EventDataTypeTx = byte(0x03)
  36. EventDataTypeNewBlockHeader = byte(0x04)
  37. EventDataTypeRoundState = byte(0x11)
  38. EventDataTypeVote = byte(0x12)
  39. )
  40. var _ = wire.RegisterInterface(
  41. struct{ TMEventData }{},
  42. wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock},
  43. wire.ConcreteType{EventDataNewBlockHeader{}, EventDataTypeNewBlockHeader},
  44. // wire.ConcreteType{EventDataFork{}, EventDataTypeFork },
  45. wire.ConcreteType{EventDataTx{}, EventDataTypeTx},
  46. wire.ConcreteType{EventDataRoundState{}, EventDataTypeRoundState},
  47. wire.ConcreteType{EventDataVote{}, EventDataTypeVote},
  48. )
  49. // Most event messages are basic types (a block, a transaction)
  50. // but some (an input to a call tx or a receive) are more exotic
  51. type EventDataNewBlock struct {
  52. Block *Block `json:"block"`
  53. }
  54. // light weight event for benchmarking
  55. type EventDataNewBlockHeader struct {
  56. Header *Header `json:"header"`
  57. }
  58. // All txs fire EventDataTx
  59. type EventDataTx struct {
  60. Tx Tx `json:"tx"`
  61. Result []byte `json:"result"`
  62. Log string `json:"log"`
  63. Error string `json:"error"`
  64. }
  65. // NOTE: This goes into the replay WAL
  66. type EventDataRoundState struct {
  67. Height int `json:"height"`
  68. Round int `json:"round"`
  69. Step string `json:"step"`
  70. // private, not exposed to websockets
  71. RoundState interface{} `json:"-"`
  72. }
  73. type EventDataVote struct {
  74. Index int
  75. Address []byte
  76. Vote *Vote
  77. }
  78. func (_ EventDataNewBlock) AssertIsTMEventData() {}
  79. func (_ EventDataNewBlockHeader) AssertIsTMEventData() {}
  80. func (_ EventDataTx) AssertIsTMEventData() {}
  81. func (_ EventDataRoundState) AssertIsTMEventData() {}
  82. func (_ EventDataVote) AssertIsTMEventData() {}