2015-11-02 07:39:53 -08:00
|
|
|
package types
|
|
|
|
|
|
|
|
import "github.com/tendermint/go-wire"
|
|
|
|
|
|
|
|
const (
|
2016-01-18 14:37:42 -08:00
|
|
|
RequestTypeEcho = byte(0x01)
|
|
|
|
RequestTypeFlush = byte(0x02)
|
|
|
|
RequestTypeInfo = byte(0x03)
|
|
|
|
RequestTypeSetOption = byte(0x04)
|
2015-11-27 10:14:46 -08:00
|
|
|
// reserved for GetOption = byte(0x05)
|
2015-11-09 16:29:45 -08:00
|
|
|
|
2016-01-18 14:37:42 -08:00
|
|
|
ResponseTypeException = byte(0x10)
|
|
|
|
ResponseTypeEcho = byte(0x11)
|
|
|
|
ResponseTypeFlush = byte(0x12)
|
|
|
|
ResponseTypeInfo = byte(0x13)
|
|
|
|
ResponseTypeSetOption = byte(0x14)
|
2015-11-27 10:14:46 -08:00
|
|
|
// reserved for GetOption = byte(0x15)
|
|
|
|
|
2016-01-23 20:49:15 -08:00
|
|
|
RequestTypeAppendTx = byte(0x21)
|
|
|
|
RequestTypeCheckTx = byte(0x22)
|
|
|
|
RequestTypeGetHash = byte(0x23)
|
|
|
|
RequestTypeQuery = byte(0x24)
|
|
|
|
|
|
|
|
ResponseTypeAppendTx = byte(0x31)
|
|
|
|
ResponseTypeCheckTx = byte(0x32)
|
|
|
|
ResponseTypeGetHash = byte(0x33)
|
|
|
|
ResponseTypeQuery = byte(0x34)
|
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
|
|
|
}
|
|
|
|
|
2016-01-18 14:37:42 -08:00
|
|
|
type RequestQuery struct {
|
|
|
|
QueryBytes []byte
|
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
type Request interface {
|
|
|
|
AssertRequestType()
|
|
|
|
}
|
|
|
|
|
2016-01-23 20:49:15 -08:00
|
|
|
func (_ RequestEcho) AssertRequestType() {}
|
|
|
|
func (_ RequestFlush) AssertRequestType() {}
|
|
|
|
func (_ RequestInfo) AssertRequestType() {}
|
|
|
|
func (_ RequestSetOption) AssertRequestType() {}
|
|
|
|
func (_ RequestAppendTx) AssertRequestType() {}
|
|
|
|
func (_ RequestCheckTx) AssertRequestType() {}
|
|
|
|
func (_ RequestGetHash) AssertRequestType() {}
|
|
|
|
func (_ RequestQuery) AssertRequestType() {}
|
2015-11-02 07:39:53 -08:00
|
|
|
|
|
|
|
var _ = wire.RegisterInterface(
|
|
|
|
struct{ Request }{},
|
2016-01-18 14:37:42 -08:00
|
|
|
wire.ConcreteType{RequestEcho{}, RequestTypeEcho},
|
|
|
|
wire.ConcreteType{RequestFlush{}, RequestTypeFlush},
|
|
|
|
wire.ConcreteType{RequestInfo{}, RequestTypeInfo},
|
|
|
|
wire.ConcreteType{RequestSetOption{}, RequestTypeSetOption},
|
|
|
|
wire.ConcreteType{RequestAppendTx{}, RequestTypeAppendTx},
|
|
|
|
wire.ConcreteType{RequestCheckTx{}, RequestTypeCheckTx},
|
|
|
|
wire.ConcreteType{RequestGetHash{}, RequestTypeGetHash},
|
|
|
|
wire.ConcreteType{RequestQuery{}, RequestTypeQuery},
|
2015-11-02 07:39:53 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
2016-01-23 20:49:15 -08:00
|
|
|
type ResponseException struct {
|
|
|
|
Error string
|
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
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 {
|
2016-01-25 08:01:18 -08:00
|
|
|
Info string
|
2015-11-09 16:29:45 -08:00
|
|
|
}
|
|
|
|
|
2015-11-27 10:14:46 -08:00
|
|
|
type ResponseSetOption struct {
|
2016-01-25 08:01:18 -08:00
|
|
|
Log string
|
2015-11-27 10:14:46 -08:00
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
type ResponseAppendTx struct {
|
2016-01-25 08:01:18 -08:00
|
|
|
Code RetCode
|
|
|
|
Result []byte
|
|
|
|
Log string
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type ResponseCheckTx struct {
|
2016-01-25 08:01:18 -08:00
|
|
|
Code RetCode
|
|
|
|
Result []byte
|
|
|
|
Log string
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-08 16:52:02 -08:00
|
|
|
type ResponseGetHash struct {
|
|
|
|
Hash []byte
|
2016-01-25 08:01:18 -08:00
|
|
|
Log string
|
2015-11-02 07:39:53 -08:00
|
|
|
}
|
|
|
|
|
2016-01-18 14:37:42 -08:00
|
|
|
type ResponseQuery struct {
|
|
|
|
Result []byte
|
2016-01-25 08:01:18 -08:00
|
|
|
Log string
|
2016-01-18 14:37:42 -08:00
|
|
|
}
|
|
|
|
|
2015-11-02 07:39:53 -08:00
|
|
|
type Response interface {
|
|
|
|
AssertResponseType()
|
|
|
|
}
|
|
|
|
|
2016-01-23 20:49:15 -08:00
|
|
|
func (_ ResponseEcho) AssertResponseType() {}
|
|
|
|
func (_ ResponseFlush) AssertResponseType() {}
|
|
|
|
func (_ ResponseInfo) AssertResponseType() {}
|
|
|
|
func (_ ResponseSetOption) AssertResponseType() {}
|
|
|
|
func (_ ResponseAppendTx) AssertResponseType() {}
|
|
|
|
func (_ ResponseCheckTx) AssertResponseType() {}
|
|
|
|
func (_ ResponseGetHash) AssertResponseType() {}
|
|
|
|
func (_ ResponseException) AssertResponseType() {}
|
|
|
|
func (_ ResponseQuery) AssertResponseType() {}
|
2015-11-02 07:39:53 -08:00
|
|
|
|
|
|
|
var _ = wire.RegisterInterface(
|
|
|
|
struct{ Response }{},
|
2016-01-18 14:37:42 -08:00
|
|
|
wire.ConcreteType{ResponseEcho{}, ResponseTypeEcho},
|
|
|
|
wire.ConcreteType{ResponseFlush{}, ResponseTypeFlush},
|
|
|
|
wire.ConcreteType{ResponseInfo{}, ResponseTypeInfo},
|
|
|
|
wire.ConcreteType{ResponseSetOption{}, ResponseTypeSetOption},
|
|
|
|
wire.ConcreteType{ResponseAppendTx{}, ResponseTypeAppendTx},
|
|
|
|
wire.ConcreteType{ResponseCheckTx{}, ResponseTypeCheckTx},
|
|
|
|
wire.ConcreteType{ResponseGetHash{}, ResponseTypeGetHash},
|
|
|
|
wire.ConcreteType{ResponseException{}, ResponseTypeException},
|
|
|
|
wire.ConcreteType{ResponseQuery{}, ResponseTypeQuery},
|
2015-11-02 07:39:53 -08:00
|
|
|
)
|