2015-11-02 07:39:53 -08:00
|
|
|
package types
|
|
|
|
|
|
|
|
import "github.com/tendermint/go-wire"
|
|
|
|
|
|
|
|
const (
|
2015-11-27 10:14:46 -08:00
|
|
|
requestTypeEcho = byte(0x01)
|
|
|
|
requestTypeFlush = byte(0x02)
|
|
|
|
requestTypeInfo = byte(0x03)
|
|
|
|
requestTypeSetOption = byte(0x04)
|
|
|
|
// reserved for GetOption = byte(0x05)
|
2015-11-09 16:29:45 -08:00
|
|
|
|
|
|
|
responseTypeException = byte(0x10)
|
|
|
|
responseTypeEcho = byte(0x11)
|
|
|
|
responseTypeFlush = byte(0x12)
|
|
|
|
responseTypeInfo = byte(0x13)
|
2015-11-27 10:14:46 -08:00
|
|
|
responseTypeSetOption = byte(0x14)
|
|
|
|
// reserved for GetOption = byte(0x15)
|
|
|
|
|
|
|
|
requestTypeAppendTx = byte(0x21)
|
2016-01-08 16:52:02 -08:00
|
|
|
requestTypeCheckTx = byte(0x22)
|
|
|
|
requestTypeGetHash = byte(0x23)
|
|
|
|
requestTypeAddListener = byte(0x24)
|
|
|
|
requestTypeRemListener = byte(0x25)
|
|
|
|
// reserved for responseTypeEvent 0x26
|
2015-11-27 10:14:46 -08:00
|
|
|
|
|
|
|
responseTypeAppendTx = byte(0x31)
|
2016-01-08 16:52:02 -08:00
|
|
|
responseTypeCheckTx = byte(0x32)
|
|
|
|
responseTypeGetHash = byte(0x33)
|
|
|
|
responseTypeAddListener = byte(0x34)
|
|
|
|
responseTypeRemListener = byte(0x35)
|
|
|
|
responseTypeEvent = byte(0x36)
|
2015-11-02 07:39:53 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
type RequestEcho struct {
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2015-11-08 15:18:58 -08:00
|
|
|
type RequestFlush struct {
|
|
|
|
}
|
|
|
|
|
2015-11-09 16:29:45 -08:00
|
|
|
type RequestInfo struct {
|
|
|
|
}
|
|
|
|
|
2015-11-27 10:14:46 -08:00
|
|
|
type RequestSetOption struct {
|
|
|
|
Key string
|
|
|
|
Value string
|
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
type RequestAppendTx struct {
|
|
|
|
TxBytes []byte
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type RequestCheckTx struct {
|
|
|
|
TxBytes []byte
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type RequestGetHash struct {
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
type RequestAddListener struct {
|
|
|
|
EventKey string
|
|
|
|
}
|
|
|
|
|
|
|
|
type RequestRemListener struct {
|
|
|
|
EventKey string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Request interface {
|
|
|
|
AssertRequestType()
|
|
|
|
}
|
|
|
|
|
2015-11-27 10:14:46 -08:00
|
|
|
func (_ RequestEcho) AssertRequestType() {}
|
|
|
|
func (_ RequestFlush) AssertRequestType() {}
|
|
|
|
func (_ RequestInfo) AssertRequestType() {}
|
|
|
|
func (_ RequestSetOption) AssertRequestType() {}
|
|
|
|
func (_ RequestAppendTx) AssertRequestType() {}
|
2016-01-08 16:52:02 -08:00
|
|
|
func (_ RequestCheckTx) AssertRequestType() {}
|
2015-11-27 10:14:46 -08:00
|
|
|
func (_ RequestGetHash) AssertRequestType() {}
|
|
|
|
func (_ RequestAddListener) AssertRequestType() {}
|
|
|
|
func (_ RequestRemListener) AssertRequestType() {}
|
2015-11-02 07:39:53 -08:00
|
|
|
|
|
|
|
var _ = wire.RegisterInterface(
|
|
|
|
struct{ Request }{},
|
|
|
|
wire.ConcreteType{RequestEcho{}, requestTypeEcho},
|
2015-11-08 15:18:58 -08:00
|
|
|
wire.ConcreteType{RequestFlush{}, requestTypeFlush},
|
2015-11-09 16:29:45 -08:00
|
|
|
wire.ConcreteType{RequestInfo{}, requestTypeInfo},
|
2015-11-27 10:14:46 -08:00
|
|
|
wire.ConcreteType{RequestSetOption{}, requestTypeSetOption},
|
2015-11-02 07:39:53 -08:00
|
|
|
wire.ConcreteType{RequestAppendTx{}, requestTypeAppendTx},
|
2016-01-08 16:52:02 -08:00
|
|
|
wire.ConcreteType{RequestCheckTx{}, requestTypeCheckTx},
|
2015-11-02 07:39:53 -08:00
|
|
|
wire.ConcreteType{RequestGetHash{}, requestTypeGetHash},
|
|
|
|
wire.ConcreteType{RequestAddListener{}, requestTypeAddListener},
|
|
|
|
wire.ConcreteType{RequestRemListener{}, requestTypeRemListener},
|
|
|
|
)
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
type ResponseEcho struct {
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2015-11-08 15:18:58 -08:00
|
|
|
type ResponseFlush struct {
|
|
|
|
}
|
|
|
|
|
2015-11-09 16:29:45 -08:00
|
|
|
type ResponseInfo struct {
|
|
|
|
Data []string
|
|
|
|
}
|
|
|
|
|
2015-11-27 10:14:46 -08:00
|
|
|
type ResponseSetOption struct {
|
|
|
|
RetCode
|
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
type ResponseAppendTx struct {
|
|
|
|
RetCode
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type ResponseCheckTx struct {
|
2015-11-02 07:39:53 -08:00
|
|
|
RetCode
|
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type ResponseGetHash struct {
|
2015-11-02 07:39:53 -08:00
|
|
|
RetCode
|
2016-01-08 16:52:02 -08:00
|
|
|
Hash []byte
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseAddListener struct {
|
|
|
|
RetCode
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseRemListener struct {
|
|
|
|
RetCode
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseException struct {
|
|
|
|
Error string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseEvent struct {
|
|
|
|
Event
|
|
|
|
}
|
|
|
|
|
|
|
|
type Response interface {
|
|
|
|
AssertResponseType()
|
|
|
|
}
|
|
|
|
|
2015-11-27 10:14:46 -08:00
|
|
|
func (_ ResponseEcho) AssertResponseType() {}
|
|
|
|
func (_ ResponseFlush) AssertResponseType() {}
|
|
|
|
func (_ ResponseInfo) AssertResponseType() {}
|
|
|
|
func (_ ResponseSetOption) AssertResponseType() {}
|
|
|
|
func (_ ResponseAppendTx) AssertResponseType() {}
|
2016-01-08 16:52:02 -08:00
|
|
|
func (_ ResponseCheckTx) AssertResponseType() {}
|
2015-11-27 10:14:46 -08:00
|
|
|
func (_ ResponseGetHash) AssertResponseType() {}
|
|
|
|
func (_ ResponseAddListener) AssertResponseType() {}
|
|
|
|
func (_ ResponseRemListener) AssertResponseType() {}
|
|
|
|
func (_ ResponseException) AssertResponseType() {}
|
|
|
|
func (_ ResponseEvent) AssertResponseType() {}
|
2015-11-02 07:39:53 -08:00
|
|
|
|
|
|
|
var _ = wire.RegisterInterface(
|
|
|
|
struct{ Response }{},
|
|
|
|
wire.ConcreteType{ResponseEcho{}, responseTypeEcho},
|
2015-11-08 15:18:58 -08:00
|
|
|
wire.ConcreteType{ResponseFlush{}, responseTypeFlush},
|
2015-11-09 16:29:45 -08:00
|
|
|
wire.ConcreteType{ResponseInfo{}, responseTypeInfo},
|
2015-11-27 10:14:46 -08:00
|
|
|
wire.ConcreteType{ResponseSetOption{}, responseTypeSetOption},
|
2015-11-02 07:39:53 -08:00
|
|
|
wire.ConcreteType{ResponseAppendTx{}, responseTypeAppendTx},
|
2016-01-08 16:52:02 -08:00
|
|
|
wire.ConcreteType{ResponseCheckTx{}, responseTypeCheckTx},
|
2015-11-02 07:39:53 -08:00
|
|
|
wire.ConcreteType{ResponseGetHash{}, responseTypeGetHash},
|
|
|
|
wire.ConcreteType{ResponseAddListener{}, responseTypeAddListener},
|
|
|
|
wire.ConcreteType{ResponseRemListener{}, responseTypeRemListener},
|
|
|
|
wire.ConcreteType{ResponseException{}, responseTypeException},
|
|
|
|
wire.ConcreteType{ResponseEvent{}, responseTypeEvent},
|
|
|
|
)
|