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.

172 lines
4.2 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. package types
  2. import "github.com/tendermint/go-wire"
  3. const (
  4. requestTypeEcho = byte(0x01)
  5. requestTypeFlush = byte(0x02)
  6. requestTypeInfo = byte(0x03)
  7. requestTypeSetOption = byte(0x04)
  8. // reserved for GetOption = byte(0x05)
  9. responseTypeException = byte(0x10)
  10. responseTypeEcho = byte(0x11)
  11. responseTypeFlush = byte(0x12)
  12. responseTypeInfo = byte(0x13)
  13. responseTypeSetOption = byte(0x14)
  14. // reserved for GetOption = byte(0x15)
  15. requestTypeAppendTx = byte(0x21)
  16. requestTypeCheckTx = byte(0x22)
  17. requestTypeGetHash = byte(0x23)
  18. requestTypeAddListener = byte(0x24)
  19. requestTypeRemListener = byte(0x25)
  20. // reserved for responseTypeEvent 0x26
  21. responseTypeAppendTx = byte(0x31)
  22. responseTypeCheckTx = byte(0x32)
  23. responseTypeGetHash = byte(0x33)
  24. responseTypeAddListener = byte(0x34)
  25. responseTypeRemListener = byte(0x35)
  26. responseTypeEvent = byte(0x36)
  27. )
  28. //----------------------------------------
  29. type RequestEcho struct {
  30. Message string
  31. }
  32. type RequestFlush struct {
  33. }
  34. type RequestInfo struct {
  35. }
  36. type RequestSetOption struct {
  37. Key string
  38. Value string
  39. }
  40. type RequestAppendTx struct {
  41. TxBytes []byte
  42. }
  43. type RequestCheckTx struct {
  44. TxBytes []byte
  45. }
  46. type RequestGetHash struct {
  47. }
  48. type RequestAddListener struct {
  49. EventKey string
  50. }
  51. type RequestRemListener struct {
  52. EventKey string
  53. }
  54. type Request interface {
  55. AssertRequestType()
  56. }
  57. func (_ RequestEcho) AssertRequestType() {}
  58. func (_ RequestFlush) AssertRequestType() {}
  59. func (_ RequestInfo) AssertRequestType() {}
  60. func (_ RequestSetOption) AssertRequestType() {}
  61. func (_ RequestAppendTx) AssertRequestType() {}
  62. func (_ RequestCheckTx) AssertRequestType() {}
  63. func (_ RequestGetHash) AssertRequestType() {}
  64. func (_ RequestAddListener) AssertRequestType() {}
  65. func (_ RequestRemListener) AssertRequestType() {}
  66. var _ = wire.RegisterInterface(
  67. struct{ Request }{},
  68. wire.ConcreteType{RequestEcho{}, requestTypeEcho},
  69. wire.ConcreteType{RequestFlush{}, requestTypeFlush},
  70. wire.ConcreteType{RequestInfo{}, requestTypeInfo},
  71. wire.ConcreteType{RequestSetOption{}, requestTypeSetOption},
  72. wire.ConcreteType{RequestAppendTx{}, requestTypeAppendTx},
  73. wire.ConcreteType{RequestCheckTx{}, requestTypeCheckTx},
  74. wire.ConcreteType{RequestGetHash{}, requestTypeGetHash},
  75. wire.ConcreteType{RequestAddListener{}, requestTypeAddListener},
  76. wire.ConcreteType{RequestRemListener{}, requestTypeRemListener},
  77. )
  78. //----------------------------------------
  79. type ResponseEcho struct {
  80. Message string
  81. }
  82. type ResponseFlush struct {
  83. }
  84. type ResponseInfo struct {
  85. Data []string
  86. }
  87. type ResponseSetOption struct {
  88. RetCode
  89. }
  90. type ResponseAppendTx struct {
  91. RetCode
  92. }
  93. type ResponseCheckTx struct {
  94. RetCode
  95. }
  96. type ResponseGetHash struct {
  97. RetCode
  98. Hash []byte
  99. }
  100. type ResponseAddListener struct {
  101. RetCode
  102. }
  103. type ResponseRemListener struct {
  104. RetCode
  105. }
  106. type ResponseException struct {
  107. Error string
  108. }
  109. type ResponseEvent struct {
  110. Event
  111. }
  112. type Response interface {
  113. AssertResponseType()
  114. }
  115. func (_ ResponseEcho) AssertResponseType() {}
  116. func (_ ResponseFlush) AssertResponseType() {}
  117. func (_ ResponseInfo) AssertResponseType() {}
  118. func (_ ResponseSetOption) AssertResponseType() {}
  119. func (_ ResponseAppendTx) AssertResponseType() {}
  120. func (_ ResponseCheckTx) AssertResponseType() {}
  121. func (_ ResponseGetHash) AssertResponseType() {}
  122. func (_ ResponseAddListener) AssertResponseType() {}
  123. func (_ ResponseRemListener) AssertResponseType() {}
  124. func (_ ResponseException) AssertResponseType() {}
  125. func (_ ResponseEvent) AssertResponseType() {}
  126. var _ = wire.RegisterInterface(
  127. struct{ Response }{},
  128. wire.ConcreteType{ResponseEcho{}, responseTypeEcho},
  129. wire.ConcreteType{ResponseFlush{}, responseTypeFlush},
  130. wire.ConcreteType{ResponseInfo{}, responseTypeInfo},
  131. wire.ConcreteType{ResponseSetOption{}, responseTypeSetOption},
  132. wire.ConcreteType{ResponseAppendTx{}, responseTypeAppendTx},
  133. wire.ConcreteType{ResponseCheckTx{}, responseTypeCheckTx},
  134. wire.ConcreteType{ResponseGetHash{}, responseTypeGetHash},
  135. wire.ConcreteType{ResponseAddListener{}, responseTypeAddListener},
  136. wire.ConcreteType{ResponseRemListener{}, responseTypeRemListener},
  137. wire.ConcreteType{ResponseException{}, responseTypeException},
  138. wire.ConcreteType{ResponseEvent{}, responseTypeEvent},
  139. )