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.

108 lines
3.5 KiB

  1. package types
  2. import (
  3. "time"
  4. "github.com/tendermint/go-common"
  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. func EventStringApp() string { return "App" }
  26. //----------------------------------------
  27. const (
  28. EventDataTypeNewBlock = byte(0x01)
  29. EventDataTypeFork = byte(0x02)
  30. EventDataTypeTx = byte(0x03)
  31. EventDataTypeApp = byte(0x04) // Custom app event
  32. EventDataTypeRoundState = byte(0x11)
  33. EventDataTypeVote = byte(0x12)
  34. )
  35. type EventData interface {
  36. AssertIsEventData()
  37. }
  38. var _ = wire.RegisterInterface(
  39. struct{ EventData }{},
  40. wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock},
  41. // wire.ConcreteType{EventDataFork{}, EventDataTypeFork },
  42. wire.ConcreteType{EventDataTx{}, EventDataTypeTx},
  43. wire.ConcreteType{EventDataApp{}, EventDataTypeApp},
  44. wire.ConcreteType{EventDataRoundState{}, EventDataTypeRoundState},
  45. wire.ConcreteType{EventDataVote{}, EventDataTypeVote},
  46. )
  47. // Most event messages are basic types (a block, a transaction)
  48. // but some (an input to a call tx or a receive) are more exotic
  49. type EventDataNewBlock struct {
  50. Block *Block `json:"block"`
  51. }
  52. // All txs fire EventDataTx
  53. type EventDataTx struct {
  54. Tx Tx `json:"tx"`
  55. Return []byte `json:"return"`
  56. Exception string `json:"exception"`
  57. }
  58. type EventDataApp struct {
  59. Key string `json:"key"`
  60. Data []byte `json:"bytes"`
  61. }
  62. // We fire the most recent round state that led to the event
  63. // (ie. NewRound will have the previous rounds state)
  64. type EventDataRoundState struct {
  65. CurrentTime time.Time `json:"current_time"`
  66. Height int `json:"height"`
  67. Round int `json:"round"`
  68. Step int `json:"step"`
  69. LastCommitRound int `json:"last_commit_round"`
  70. StartTime time.Time `json:"start_time"`
  71. CommitTime time.Time `json:"commit_time"`
  72. Proposal *Proposal `json:"proposal"`
  73. ProposalBlock *Block `json:"proposal_block"`
  74. LockedRound int `json:"locked_round"`
  75. LockedBlock *Block `json:"locked_block"`
  76. POLRound int `json:"pol_round"`
  77. BlockPartsHeader PartSetHeader `json:"block_parts_header"`
  78. BlockParts *common.BitArray `json:"block_parts"`
  79. }
  80. type EventDataVote struct {
  81. Index int
  82. Address []byte
  83. Vote *Vote
  84. }
  85. func (_ EventDataNewBlock) AssertIsEventData() {}
  86. func (_ EventDataTx) AssertIsEventData() {}
  87. func (_ EventDataApp) AssertIsEventData() {}
  88. func (_ EventDataRoundState) AssertIsEventData() {}
  89. func (_ EventDataVote) AssertIsEventData() {}