mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
Use protobuf enums
This commit is contained in:
@ -7,53 +7,28 @@ import (
|
||||
"github.com/tendermint/go-wire"
|
||||
)
|
||||
|
||||
const (
|
||||
RequestTypeEcho = uint32(0x01)
|
||||
RequestTypeFlush = uint32(0x02)
|
||||
RequestTypeInfo = uint32(0x03)
|
||||
RequestTypeSetOption = uint32(0x04)
|
||||
// reserved for GetOption = uint32(0x05)
|
||||
|
||||
ResponseTypeException = uint32(0x10)
|
||||
ResponseTypeEcho = uint32(0x11)
|
||||
ResponseTypeFlush = uint32(0x12)
|
||||
ResponseTypeInfo = uint32(0x13)
|
||||
ResponseTypeSetOption = uint32(0x14)
|
||||
// reserved for GetOption = uint32(0x15)
|
||||
|
||||
RequestTypeAppendTx = uint32(0x21)
|
||||
RequestTypeCheckTx = uint32(0x22)
|
||||
RequestTypeGetHash = uint32(0x23)
|
||||
RequestTypeQuery = uint32(0x24)
|
||||
|
||||
ResponseTypeAppendTx = uint32(0x31)
|
||||
ResponseTypeCheckTx = uint32(0x32)
|
||||
ResponseTypeGetHash = uint32(0x33)
|
||||
ResponseTypeQuery = uint32(0x34)
|
||||
)
|
||||
|
||||
func RequestEcho(message string) *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeEcho,
|
||||
Type: MessageType_Echo,
|
||||
Data: []byte(message),
|
||||
}
|
||||
}
|
||||
|
||||
func RequestFlush() *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeFlush,
|
||||
Type: MessageType_Flush,
|
||||
}
|
||||
}
|
||||
|
||||
func RequestInfo() *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeInfo,
|
||||
Type: MessageType_Info,
|
||||
}
|
||||
}
|
||||
|
||||
func RequestSetOption(key string, value string) *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeSetOption,
|
||||
Type: MessageType_SetOption,
|
||||
Key: key,
|
||||
Value: value,
|
||||
}
|
||||
@ -61,27 +36,27 @@ func RequestSetOption(key string, value string) *Request {
|
||||
|
||||
func RequestAppendTx(txBytes []byte) *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeAppendTx,
|
||||
Type: MessageType_AppendTx,
|
||||
Data: txBytes,
|
||||
}
|
||||
}
|
||||
|
||||
func RequestCheckTx(txBytes []byte) *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeCheckTx,
|
||||
Type: MessageType_CheckTx,
|
||||
Data: txBytes,
|
||||
}
|
||||
}
|
||||
|
||||
func RequestGetHash() *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeGetHash,
|
||||
Type: MessageType_GetHash,
|
||||
}
|
||||
}
|
||||
|
||||
func RequestQuery(queryBytes []byte) *Request {
|
||||
return &Request{
|
||||
Type: RequestTypeQuery,
|
||||
Type: MessageType_Query,
|
||||
Data: queryBytes,
|
||||
}
|
||||
}
|
||||
@ -90,41 +65,41 @@ func RequestQuery(queryBytes []byte) *Request {
|
||||
|
||||
func ResponseException(errStr string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeException,
|
||||
Type: MessageType_Exception,
|
||||
Error: errStr,
|
||||
}
|
||||
}
|
||||
|
||||
func ResponseEcho(message string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeEcho,
|
||||
Type: MessageType_Echo,
|
||||
Data: []byte(message),
|
||||
}
|
||||
}
|
||||
|
||||
func ResponseFlush() *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeFlush,
|
||||
Type: MessageType_Flush,
|
||||
}
|
||||
}
|
||||
|
||||
func ResponseInfo(info string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeInfo,
|
||||
Type: MessageType_Info,
|
||||
Data: []byte(info),
|
||||
}
|
||||
}
|
||||
|
||||
func ResponseSetOption(log string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeSetOption,
|
||||
Type: MessageType_SetOption,
|
||||
Log: log,
|
||||
}
|
||||
}
|
||||
|
||||
func ResponseAppendTx(code RetCode, result []byte, log string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeAppendTx,
|
||||
Type: MessageType_AppendTx,
|
||||
Code: uint32(code),
|
||||
Data: result,
|
||||
Log: log,
|
||||
@ -133,7 +108,7 @@ func ResponseAppendTx(code RetCode, result []byte, log string) *Response {
|
||||
|
||||
func ResponseCheckTx(code RetCode, result []byte, log string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeCheckTx,
|
||||
Type: MessageType_CheckTx,
|
||||
Code: uint32(code),
|
||||
Data: result,
|
||||
Log: log,
|
||||
@ -142,7 +117,7 @@ func ResponseCheckTx(code RetCode, result []byte, log string) *Response {
|
||||
|
||||
func ResponseGetHash(hash []byte, log string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeGetHash,
|
||||
Type: MessageType_GetHash,
|
||||
Data: hash,
|
||||
Log: log,
|
||||
}
|
||||
@ -150,7 +125,7 @@ func ResponseGetHash(hash []byte, log string) *Response {
|
||||
|
||||
func ResponseQuery(code RetCode, result []byte, log string) *Response {
|
||||
return &Response{
|
||||
Type: ResponseTypeQuery,
|
||||
Type: MessageType_Query,
|
||||
Code: uint32(code),
|
||||
Data: result,
|
||||
Log: log,
|
||||
|
Reference in New Issue
Block a user