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.

184 lines
4.6 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
  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. requestTypeGetHash = byte(0x22)
  17. requestTypeCommit = byte(0x23)
  18. requestTypeRollback = byte(0x24)
  19. requestTypeAddListener = byte(0x25)
  20. requestTypeRemListener = byte(0x26)
  21. // reserved for responseTypeEvent 0x27
  22. responseTypeAppendTx = byte(0x31)
  23. responseTypeGetHash = byte(0x32)
  24. responseTypeCommit = byte(0x33)
  25. responseTypeRollback = byte(0x34)
  26. responseTypeAddListener = byte(0x35)
  27. responseTypeRemListener = byte(0x36)
  28. responseTypeEvent = byte(0x37)
  29. )
  30. //----------------------------------------
  31. type RequestEcho struct {
  32. Message string
  33. }
  34. type RequestFlush struct {
  35. }
  36. type RequestInfo struct {
  37. }
  38. type RequestSetOption struct {
  39. Key string
  40. Value string
  41. }
  42. type RequestAppendTx struct {
  43. TxBytes []byte
  44. }
  45. type RequestGetHash struct {
  46. }
  47. type RequestCommit struct {
  48. }
  49. type RequestRollback struct {
  50. }
  51. type RequestAddListener struct {
  52. EventKey string
  53. }
  54. type RequestRemListener struct {
  55. EventKey string
  56. }
  57. type Request interface {
  58. AssertRequestType()
  59. }
  60. func (_ RequestEcho) AssertRequestType() {}
  61. func (_ RequestFlush) AssertRequestType() {}
  62. func (_ RequestInfo) AssertRequestType() {}
  63. func (_ RequestSetOption) AssertRequestType() {}
  64. func (_ RequestAppendTx) AssertRequestType() {}
  65. func (_ RequestGetHash) AssertRequestType() {}
  66. func (_ RequestCommit) AssertRequestType() {}
  67. func (_ RequestRollback) AssertRequestType() {}
  68. func (_ RequestAddListener) AssertRequestType() {}
  69. func (_ RequestRemListener) AssertRequestType() {}
  70. var _ = wire.RegisterInterface(
  71. struct{ Request }{},
  72. wire.ConcreteType{RequestEcho{}, requestTypeEcho},
  73. wire.ConcreteType{RequestFlush{}, requestTypeFlush},
  74. wire.ConcreteType{RequestInfo{}, requestTypeInfo},
  75. wire.ConcreteType{RequestSetOption{}, requestTypeSetOption},
  76. wire.ConcreteType{RequestAppendTx{}, requestTypeAppendTx},
  77. wire.ConcreteType{RequestGetHash{}, requestTypeGetHash},
  78. wire.ConcreteType{RequestCommit{}, requestTypeCommit},
  79. wire.ConcreteType{RequestRollback{}, requestTypeRollback},
  80. wire.ConcreteType{RequestAddListener{}, requestTypeAddListener},
  81. wire.ConcreteType{RequestRemListener{}, requestTypeRemListener},
  82. )
  83. //----------------------------------------
  84. type ResponseEcho struct {
  85. Message string
  86. }
  87. type ResponseFlush struct {
  88. }
  89. type ResponseInfo struct {
  90. Data []string
  91. }
  92. type ResponseSetOption struct {
  93. RetCode
  94. }
  95. type ResponseAppendTx struct {
  96. RetCode
  97. }
  98. type ResponseGetHash struct {
  99. RetCode
  100. Hash []byte
  101. }
  102. type ResponseCommit struct {
  103. RetCode
  104. }
  105. type ResponseRollback struct {
  106. RetCode
  107. }
  108. type ResponseAddListener struct {
  109. RetCode
  110. }
  111. type ResponseRemListener struct {
  112. RetCode
  113. }
  114. type ResponseException struct {
  115. Error string
  116. }
  117. type ResponseEvent struct {
  118. Event
  119. }
  120. type Response interface {
  121. AssertResponseType()
  122. }
  123. func (_ ResponseEcho) AssertResponseType() {}
  124. func (_ ResponseFlush) AssertResponseType() {}
  125. func (_ ResponseInfo) AssertResponseType() {}
  126. func (_ ResponseSetOption) AssertResponseType() {}
  127. func (_ ResponseAppendTx) AssertResponseType() {}
  128. func (_ ResponseGetHash) AssertResponseType() {}
  129. func (_ ResponseCommit) AssertResponseType() {}
  130. func (_ ResponseRollback) AssertResponseType() {}
  131. func (_ ResponseAddListener) AssertResponseType() {}
  132. func (_ ResponseRemListener) AssertResponseType() {}
  133. func (_ ResponseException) AssertResponseType() {}
  134. func (_ ResponseEvent) AssertResponseType() {}
  135. var _ = wire.RegisterInterface(
  136. struct{ Response }{},
  137. wire.ConcreteType{ResponseEcho{}, responseTypeEcho},
  138. wire.ConcreteType{ResponseFlush{}, responseTypeFlush},
  139. wire.ConcreteType{ResponseInfo{}, responseTypeInfo},
  140. wire.ConcreteType{ResponseSetOption{}, responseTypeSetOption},
  141. wire.ConcreteType{ResponseAppendTx{}, responseTypeAppendTx},
  142. wire.ConcreteType{ResponseGetHash{}, responseTypeGetHash},
  143. wire.ConcreteType{ResponseCommit{}, responseTypeCommit},
  144. wire.ConcreteType{ResponseRollback{}, responseTypeRollback},
  145. wire.ConcreteType{ResponseAddListener{}, responseTypeAddListener},
  146. wire.ConcreteType{ResponseRemListener{}, responseTypeRemListener},
  147. wire.ConcreteType{ResponseException{}, responseTypeException},
  148. wire.ConcreteType{ResponseEvent{}, responseTypeEvent},
  149. )