Browse Source

use real protobuf message types

pull/1780/head
Ethan Buchman 9 years ago
parent
commit
35f4f0e271
6 changed files with 1455 additions and 245 deletions
  1. +21
    -21
      client/local_client.go
  2. +71
    -43
      client/remote_client.go
  3. +32
    -31
      server/server.go
  4. +46
    -72
      types/messages.go
  5. +1161
    -66
      types/types.pb.go
  6. +124
    -12
      types/types.proto

+ 21
- 21
client/local_client.go View File

@ -38,13 +38,13 @@ func (app *localClient) Stop() bool {
func (app *localClient) FlushAsync() *ReqRes {
// Do nothing
return newLocalReqRes(types.RequestFlush(), nil)
return newLocalReqRes(types.ToRequestFlush(), nil)
}
func (app *localClient) EchoAsync(msg string) *ReqRes {
return app.callback(
types.RequestEcho(msg),
types.ResponseEcho(msg),
types.ToRequestEcho(msg),
types.ToResponseEcho(msg),
)
}
@ -53,8 +53,8 @@ func (app *localClient) InfoAsync() *ReqRes {
info := app.Application.Info()
app.mtx.Unlock()
return app.callback(
types.RequestInfo(),
types.ResponseInfo(info),
types.ToRequestInfo(),
types.ToResponseInfo(info),
)
}
@ -63,8 +63,8 @@ func (app *localClient) SetOptionAsync(key string, value string) *ReqRes {
log := app.Application.SetOption(key, value)
app.mtx.Unlock()
return app.callback(
types.RequestSetOption(key, value),
types.ResponseSetOption(log),
types.ToRequestSetOption(key, value),
types.ToResponseSetOption(log),
)
}
@ -73,8 +73,8 @@ func (app *localClient) AppendTxAsync(tx []byte) *ReqRes {
res := app.Application.AppendTx(tx)
app.mtx.Unlock()
return app.callback(
types.RequestAppendTx(tx),
types.ResponseAppendTx(res.Code, res.Data, res.Log),
types.ToRequestAppendTx(tx),
types.ToResponseAppendTx(res.Code, res.Data, res.Log),
)
}
@ -83,8 +83,8 @@ func (app *localClient) CheckTxAsync(tx []byte) *ReqRes {
res := app.Application.CheckTx(tx)
app.mtx.Unlock()
return app.callback(
types.RequestCheckTx(tx),
types.ResponseCheckTx(res.Code, res.Data, res.Log),
types.ToRequestCheckTx(tx),
types.ToResponseCheckTx(res.Code, res.Data, res.Log),
)
}
@ -93,8 +93,8 @@ func (app *localClient) QueryAsync(tx []byte) *ReqRes {
res := app.Application.Query(tx)
app.mtx.Unlock()
return app.callback(
types.RequestQuery(tx),
types.ResponseQuery(res.Code, res.Data, res.Log),
types.ToRequestQuery(tx),
types.ToResponseQuery(res.Code, res.Data, res.Log),
)
}
@ -103,8 +103,8 @@ func (app *localClient) CommitAsync() *ReqRes {
res := app.Application.Commit()
app.mtx.Unlock()
return app.callback(
types.RequestCommit(),
types.ResponseCommit(res.Code, res.Data, res.Log),
types.ToRequestCommit(),
types.ToResponseCommit(res.Code, res.Data, res.Log),
)
}
@ -114,8 +114,8 @@ func (app *localClient) InitChainAsync(validators []*types.Validator) *ReqRes {
bcApp.InitChain(validators)
}
reqRes := app.callback(
types.RequestInitChain(validators),
types.ResponseInitChain(),
types.ToRequestInitChain(validators),
types.ToResponseInitChain(),
)
app.mtx.Unlock()
return reqRes
@ -128,8 +128,8 @@ func (app *localClient) BeginBlockAsync(height uint64) *ReqRes {
}
app.mtx.Unlock()
return app.callback(
types.RequestBeginBlock(height),
types.ResponseBeginBlock(),
types.ToRequestBeginBlock(height),
types.ToResponseBeginBlock(),
)
}
@ -141,8 +141,8 @@ func (app *localClient) EndBlockAsync(height uint64) *ReqRes {
}
app.mtx.Unlock()
return app.callback(
types.RequestEndBlock(height),
types.ResponseEndBlock(validators),
types.ToRequestEndBlock(height),
types.ToResponseEndBlock(validators),
)
}


+ 71
- 43
client/remote_client.go View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net"
"reflect"
"sync"
"time"
@ -13,6 +14,11 @@ import (
"github.com/tendermint/tmsp/types"
)
const (
OK = types.CodeType_OK
LOG = ""
)
const reqQueueSize = 256 // TODO make configurable
const maxResponseSize = 1048576 // 1MB TODO make configurable
const flushThrottleMS = 20 // Don't wait longer than...
@ -122,7 +128,7 @@ func (cli *remoteClient) sendRequestsRoutine(conn net.Conn) {
select {
case <-cli.flushTimer.Ch:
select {
case cli.reqQueue <- NewReqRes(types.RequestFlush()):
case cli.reqQueue <- NewReqRes(types.ToRequestFlush()):
default:
// Probably will fill the buffer, or retry later.
}
@ -136,7 +142,7 @@ func (cli *remoteClient) sendRequestsRoutine(conn net.Conn) {
return
}
// log.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
if reqres.Request.Type == types.MessageType_Flush {
if _, ok := reqres.Request.Requests.(*types.Request_Flush); ok {
err = w.Flush()
if err != nil {
cli.StopForError(err)
@ -156,10 +162,10 @@ func (cli *remoteClient) recvResponseRoutine(conn net.Conn) {
cli.StopForError(err)
return
}
switch res.Type {
case types.MessageType_Exception:
switch r := res.Responses.(type) {
case *types.Response_Exception:
// XXX After setting cli.err, release waiters (e.g. reqres.Done())
cli.StopForError(errors.New(res.Error))
cli.StopForError(errors.New(r.Exception.Error))
default:
// log.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
err := cli.didRecvResponse(res)
@ -183,12 +189,12 @@ func (cli *remoteClient) didRecvResponse(res *types.Response) error {
// Get the first ReqRes
next := cli.reqSent.Front()
if next == nil {
return fmt.Errorf("Unexpected result type %v when nothing expected", res.Type)
return fmt.Errorf("Unexpected result type %v when nothing expected", reflect.TypeOf(res.Responses))
}
reqres := next.Value.(*ReqRes)
if !resMatchesReq(reqres.Request, res) {
return fmt.Errorf("Unexpected result type %v when response to %v expected",
res.Type, reqres.Request.Type)
reflect.TypeOf(res.Responses), reflect.TypeOf(reqres.Request.Requests))
}
reqres.Response = res // Set response
@ -211,128 +217,128 @@ func (cli *remoteClient) didRecvResponse(res *types.Response) error {
//----------------------------------------
func (cli *remoteClient) EchoAsync(msg string) *ReqRes {
return cli.queueRequest(types.RequestEcho(msg))
return cli.queueRequest(types.ToRequestEcho(msg))
}
func (cli *remoteClient) FlushAsync() *ReqRes {
return cli.queueRequest(types.RequestFlush())
return cli.queueRequest(types.ToRequestFlush())
}
func (cli *remoteClient) InfoAsync() *ReqRes {
return cli.queueRequest(types.RequestInfo())
return cli.queueRequest(types.ToRequestInfo())
}
func (cli *remoteClient) SetOptionAsync(key string, value string) *ReqRes {
return cli.queueRequest(types.RequestSetOption(key, value))
return cli.queueRequest(types.ToRequestSetOption(key, value))
}
func (cli *remoteClient) AppendTxAsync(tx []byte) *ReqRes {
return cli.queueRequest(types.RequestAppendTx(tx))
return cli.queueRequest(types.ToRequestAppendTx(tx))
}
func (cli *remoteClient) CheckTxAsync(tx []byte) *ReqRes {
return cli.queueRequest(types.RequestCheckTx(tx))
return cli.queueRequest(types.ToRequestCheckTx(tx))
}
func (cli *remoteClient) QueryAsync(query []byte) *ReqRes {
return cli.queueRequest(types.RequestQuery(query))
return cli.queueRequest(types.ToRequestQuery(query))
}
func (cli *remoteClient) CommitAsync() *ReqRes {
return cli.queueRequest(types.RequestCommit())
return cli.queueRequest(types.ToRequestCommit())
}
func (cli *remoteClient) InitChainAsync(validators []*types.Validator) *ReqRes {
return cli.queueRequest(types.RequestInitChain(validators))
return cli.queueRequest(types.ToRequestInitChain(validators))
}
func (cli *remoteClient) BeginBlockAsync(height uint64) *ReqRes {
return cli.queueRequest(types.RequestBeginBlock(height))
return cli.queueRequest(types.ToRequestBeginBlock(height))
}
func (cli *remoteClient) EndBlockAsync(height uint64) *ReqRes {
return cli.queueRequest(types.RequestEndBlock(height))
return cli.queueRequest(types.ToRequestEndBlock(height))
}
//----------------------------------------
func (cli *remoteClient) EchoSync(msg string) (res types.Result) {
reqres := cli.queueRequest(types.RequestEcho(msg))
reqres := cli.queueRequest(types.ToRequestEcho(msg))
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
resp := reqres.Response.GetEcho()
return types.Result{Code: OK, Data: []byte(resp.Message), Log: LOG}
}
func (cli *remoteClient) FlushSync() error {
cli.queueRequest(types.RequestFlush()).Wait()
cli.queueRequest(types.ToRequestFlush()).Wait()
return cli.err
}
func (cli *remoteClient) InfoSync() (res types.Result) {
reqres := cli.queueRequest(types.RequestInfo())
reqres := cli.queueRequest(types.ToRequestInfo())
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
resp := reqres.Response.GetInfo()
return types.Result{Code: OK, Data: []byte(resp.Info), Log: LOG}
}
func (cli *remoteClient) SetOptionSync(key string, value string) (res types.Result) {
reqres := cli.queueRequest(types.RequestSetOption(key, value))
reqres := cli.queueRequest(types.ToRequestSetOption(key, value))
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
resp := reqres.Response.GetSetOption()
return types.Result{Code: OK, Data: nil, Log: resp.Log}
}
func (cli *remoteClient) AppendTxSync(tx []byte) (res types.Result) {
reqres := cli.queueRequest(types.RequestAppendTx(tx))
reqres := cli.queueRequest(types.ToRequestAppendTx(tx))
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
resp := reqres.Response.GetAppendTx()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
func (cli *remoteClient) CheckTxSync(tx []byte) (res types.Result) {
reqres := cli.queueRequest(types.RequestCheckTx(tx))
reqres := cli.queueRequest(types.ToRequestCheckTx(tx))
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
resp := reqres.Response.GetCheckTx()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
func (cli *remoteClient) QuerySync(query []byte) (res types.Result) {
reqres := cli.queueRequest(types.RequestQuery(query))
reqres := cli.queueRequest(types.ToRequestQuery(query))
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
resp := reqres.Response.GetQuery()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
func (cli *remoteClient) CommitSync() (res types.Result) {
reqres := cli.queueRequest(types.RequestCommit())
reqres := cli.queueRequest(types.ToRequestCommit())
cli.FlushSync()
if cli.err != nil {
return types.ErrInternalError.SetLog(cli.err.Error())
}
resp := reqres.Response
resp := reqres.Response.GetCommit()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
func (cli *remoteClient) InitChainSync(validators []*types.Validator) (err error) {
cli.queueRequest(types.RequestInitChain(validators))
cli.queueRequest(types.ToRequestInitChain(validators))
cli.FlushSync()
if cli.err != nil {
return cli.err
@ -341,7 +347,7 @@ func (cli *remoteClient) InitChainSync(validators []*types.Validator) (err error
}
func (cli *remoteClient) BeginBlockSync(height uint64) (err error) {
cli.queueRequest(types.RequestBeginBlock(height))
cli.queueRequest(types.ToRequestBeginBlock(height))
cli.FlushSync()
if cli.err != nil {
return cli.err
@ -350,12 +356,12 @@ func (cli *remoteClient) BeginBlockSync(height uint64) (err error) {
}
func (cli *remoteClient) EndBlockSync(height uint64) (validators []*types.Validator, err error) {
reqres := cli.queueRequest(types.RequestEndBlock(height))
reqres := cli.queueRequest(types.ToRequestEndBlock(height))
cli.FlushSync()
if cli.err != nil {
return nil, cli.err
}
return reqres.Response.Validators, nil
return reqres.Response.GetEndBlock().Diffs, nil
}
//----------------------------------------
@ -366,8 +372,8 @@ func (cli *remoteClient) queueRequest(req *types.Request) *ReqRes {
cli.reqQueue <- reqres
// Maybe auto-flush, or unset auto-flush
switch req.Type {
case types.MessageType_Flush:
switch req.Requests.(type) {
case *types.Request_Flush:
cli.flushTimer.Unset()
default:
cli.flushTimer.Set()
@ -379,5 +385,27 @@ func (cli *remoteClient) queueRequest(req *types.Request) *ReqRes {
//----------------------------------------
func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
return req.Type == res.Type
switch req.Requests.(type) {
case *types.Request_Echo:
_, ok = res.Responses.(*types.Response_Echo)
case *types.Request_Flush:
_, ok = res.Responses.(*types.Response_Flush)
case *types.Request_Info:
_, ok = res.Responses.(*types.Response_Info)
case *types.Request_SetOption:
_, ok = res.Responses.(*types.Response_SetOption)
case *types.Request_AppendTx:
_, ok = res.Responses.(*types.Response_AppendTx)
case *types.Request_CheckTx:
_, ok = res.Responses.(*types.Response_CheckTx)
case *types.Request_Commit:
_, ok = res.Responses.(*types.Response_Commit)
case *types.Request_Query:
_, ok = res.Responses.(*types.Response_Query)
case *types.Request_InitChain:
_, ok = res.Responses.(*types.Response_InitChain)
case *types.Request_EndBlock:
_, ok = res.Responses.(*types.Response_EndBlock)
}
return ok
}

+ 32
- 31
server/server.go View File

@ -125,45 +125,46 @@ func (s *Server) handleRequests(closeConn chan error, conn net.Conn, responses c
}
func (s *Server) handleRequest(req *types.Request, responses chan<- *types.Response) {
switch req.Type {
case types.MessageType_Echo:
responses <- types.ResponseEcho(string(req.Data))
case types.MessageType_Flush:
responses <- types.ResponseFlush()
case types.MessageType_Info:
switch r := req.Requests.(type) {
case *types.Request_Echo:
responses <- types.ToResponseEcho(r.Echo.Message)
case *types.Request_Flush:
responses <- types.ToResponseFlush()
case *types.Request_Info:
data := s.app.Info()
responses <- types.ResponseInfo(data)
case types.MessageType_SetOption:
logStr := s.app.SetOption(req.Key, req.Value)
responses <- types.ResponseSetOption(logStr)
case types.MessageType_AppendTx:
res := s.app.AppendTx(req.Data)
responses <- types.ResponseAppendTx(res.Code, res.Data, res.Log)
case types.MessageType_CheckTx:
res := s.app.CheckTx(req.Data)
responses <- types.ResponseCheckTx(res.Code, res.Data, res.Log)
case types.MessageType_Commit:
responses <- types.ToResponseInfo(data)
case *types.Request_SetOption:
so := r.SetOption
logStr := s.app.SetOption(so.Key, so.Value)
responses <- types.ToResponseSetOption(logStr)
case *types.Request_AppendTx:
res := s.app.AppendTx(r.AppendTx.Tx)
responses <- types.ToResponseAppendTx(res.Code, res.Data, res.Log)
case *types.Request_CheckTx:
res := s.app.CheckTx(r.CheckTx.Tx)
responses <- types.ToResponseCheckTx(res.Code, res.Data, res.Log)
case *types.Request_Commit:
res := s.app.Commit()
responses <- types.ResponseCommit(res.Code, res.Data, res.Log)
case types.MessageType_Query:
res := s.app.Query(req.Data)
responses <- types.ResponseQuery(res.Code, res.Data, res.Log)
case types.MessageType_InitChain:
responses <- types.ToResponseCommit(res.Code, res.Data, res.Log)
case *types.Request_Query:
res := s.app.Query(r.Query.Query)
responses <- types.ToResponseQuery(res.Code, res.Data, res.Log)
case *types.Request_InitChain:
if app, ok := s.app.(types.BlockchainAware); ok {
app.InitChain(req.Validators)
responses <- types.ResponseInitChain()
app.InitChain(r.InitChain.Validators)
responses <- types.ToResponseInitChain()
} else {
responses <- types.ResponseInitChain()
responses <- types.ToResponseInitChain()
}
case types.MessageType_EndBlock:
case *types.Request_EndBlock:
if app, ok := s.app.(types.BlockchainAware); ok {
validators := app.EndBlock(req.Height)
responses <- types.ResponseEndBlock(validators)
validators := app.EndBlock(r.EndBlock.Height)
responses <- types.ToResponseEndBlock(validators)
} else {
responses <- types.ResponseEndBlock(nil)
responses <- types.ToResponseEndBlock(nil)
}
default:
responses <- types.ResponseException("Unknown request")
responses <- types.ToResponseException("Unknown request")
}
}
@ -178,7 +179,7 @@ func (s *Server) handleResponses(closeConn chan error, responses <-chan *types.R
closeConn <- fmt.Errorf("Error in handleResponses: %v", err.Error())
return
}
if res.Type == types.MessageType_Flush {
if _, ok := res.Responses.(*types.Response_Flush); ok {
err = bufWriter.Flush()
if err != nil {
closeConn <- fmt.Errorf("Error in handleResponses: %v", err.Error())


+ 46
- 72
types/messages.go View File

@ -7,169 +7,143 @@ import (
"github.com/tendermint/go-wire"
)
func RequestEcho(message string) *Request {
func ToRequestEcho(message string) *Request {
return &Request{
Type: MessageType_Echo,
Data: []byte(message),
Requests: &Request_Echo{&RequestEcho{}},
}
}
func RequestFlush() *Request {
func ToRequestFlush() *Request {
return &Request{
Type: MessageType_Flush,
Requests: &Request_Flush{&RequestFlush{}},
}
}
func RequestInfo() *Request {
func ToRequestInfo() *Request {
return &Request{
Type: MessageType_Info,
Requests: &Request_Info{&RequestInfo{}},
}
}
func RequestSetOption(key string, value string) *Request {
func ToRequestSetOption(key string, value string) *Request {
return &Request{
Type: MessageType_SetOption,
Key: key,
Value: value,
Requests: &Request_SetOption{&RequestSetOption{key, value}},
}
}
func RequestAppendTx(txBytes []byte) *Request {
func ToRequestAppendTx(txBytes []byte) *Request {
return &Request{
Type: MessageType_AppendTx,
Data: txBytes,
Requests: &Request_AppendTx{&RequestAppendTx{txBytes}},
}
}
func RequestCheckTx(txBytes []byte) *Request {
func ToRequestCheckTx(txBytes []byte) *Request {
return &Request{
Type: MessageType_CheckTx,
Data: txBytes,
Requests: &Request_CheckTx{&RequestCheckTx{txBytes}},
}
}
func RequestCommit() *Request {
func ToRequestCommit() *Request {
return &Request{
Type: MessageType_Commit,
Requests: &Request_Commit{&RequestCommit{}},
}
}
func RequestQuery(queryBytes []byte) *Request {
func ToRequestQuery(queryBytes []byte) *Request {
return &Request{
Type: MessageType_Query,
Data: queryBytes,
Requests: &Request_Query{&RequestQuery{queryBytes}},
}
}
func RequestInitChain(validators []*Validator) *Request {
func ToRequestInitChain(validators []*Validator) *Request {
return &Request{
Type: MessageType_InitChain,
Validators: validators,
Requests: &Request_InitChain{&RequestInitChain{validators}},
}
}
func RequestBeginBlock(height uint64) *Request {
func ToRequestBeginBlock(height uint64) *Request {
return &Request{
Type: MessageType_BeginBlock,
Height: height,
Requests: &Request_BeginBlock{&RequestBeginBlock{height}},
}
}
func RequestEndBlock(height uint64) *Request {
func ToRequestEndBlock(height uint64) *Request {
return &Request{
Type: MessageType_EndBlock,
Height: height,
Requests: &Request_EndBlock{&RequestEndBlock{height}},
}
}
//----------------------------------------
func ResponseException(errStr string) *Response {
func ToResponseException(errStr string) *Response {
return &Response{
Type: MessageType_Exception,
Error: errStr,
Responses: &Response_Exception{&ResponseException{errStr}},
}
}
func ResponseEcho(message string) *Response {
func ToResponseEcho(message string) *Response {
return &Response{
Type: MessageType_Echo,
Data: []byte(message),
Responses: &Response_Echo{&ResponseEcho{message}},
}
}
func ResponseFlush() *Response {
func ToResponseFlush() *Response {
return &Response{
Type: MessageType_Flush,
Responses: &Response_Flush{&ResponseFlush{}},
}
}
func ResponseInfo(info string) *Response {
func ToResponseInfo(info string) *Response {
return &Response{
Type: MessageType_Info,
Data: []byte(info),
Responses: &Response_Info{&ResponseInfo{info}},
}
}
func ResponseSetOption(log string) *Response {
func ToResponseSetOption(log string) *Response {
return &Response{
Type: MessageType_SetOption,
Log: log,
Responses: &Response_SetOption{&ResponseSetOption{log}},
}
}
func ResponseAppendTx(code CodeType, data []byte, log string) *Response {
func ToResponseAppendTx(code CodeType, data []byte, log string) *Response {
return &Response{
Type: MessageType_AppendTx,
Code: code,
Data: data,
Log: log,
Responses: &Response_AppendTx{&ResponseAppendTx{code, data, log}},
}
}
func ResponseCheckTx(code CodeType, data []byte, log string) *Response {
func ToResponseCheckTx(code CodeType, data []byte, log string) *Response {
return &Response{
Type: MessageType_CheckTx,
Code: code,
Data: data,
Log: log,
Responses: &Response_CheckTx{&ResponseCheckTx{code, data, log}},
}
}
func ResponseCommit(code CodeType, data []byte, log string) *Response {
func ToResponseCommit(code CodeType, data []byte, log string) *Response {
return &Response{
Type: MessageType_Commit,
Code: code,
Data: data,
Log: log,
Responses: &Response_Commit{&ResponseCommit{code, data, log}},
}
}
func ResponseQuery(code CodeType, data []byte, log string) *Response {
func ToResponseQuery(code CodeType, data []byte, log string) *Response {
return &Response{
Type: MessageType_Query,
Code: code,
Data: data,
Log: log,
Responses: &Response_Query{&ResponseQuery{code, data, log}},
}
}
func ResponseInitChain() *Response {
func ToResponseInitChain() *Response {
return &Response{
Type: MessageType_InitChain,
Responses: &Response_InitChain{&ResponseInitChain{}},
}
}
func ResponseBeginBlock() *Response {
func ToResponseBeginBlock() *Response {
return &Response{
Type: MessageType_BeginBlock,
Responses: &Response_BeginBlock{&ResponseBeginBlock{}},
}
}
func ResponseEndBlock(validators []*Validator) *Response {
func ToResponseEndBlock(validators []*Validator) *Response {
return &Response{
Type: MessageType_EndBlock,
Validators: validators,
Responses: &Response_EndBlock{&ResponseEndBlock{validators}},
}
}


+ 1161
- 66
types/types.pb.go
File diff suppressed because it is too large
View File


+ 124
- 12
types/types.proto View File

@ -70,24 +70,136 @@ enum CodeType {
// Request types
message Request {
MessageType type = 1;
bytes data = 2;
string key = 3;
string value = 4;
repeated Validator validators = 5;
uint64 height = 6;
oneof requests{
RequestEcho echo = 1;
RequestFlush flush = 2;
RequestInfo info = 3;
RequestSetOption set_option = 4;
RequestAppendTx append_tx = 5;
RequestCheckTx check_tx = 6;
RequestCommit commit = 7;
RequestQuery query = 8;
RequestInitChain init_chain = 9;
RequestBeginBlock begin_block = 10;
RequestEndBlock end_block = 11;
}
}
message RequestEcho {
string message = 1;
}
message RequestFlush {
}
message RequestInfo {
}
message RequestSetOption{
string key = 1;
string value = 2;
}
message RequestAppendTx{
bytes tx = 1;
}
message RequestCheckTx{
bytes tx = 1;
}
message RequestQuery{
bytes query = 1;
}
message RequestCommit{
}
message RequestInitChain{
repeated Validator validators = 1;
}
message RequestBeginBlock{
uint64 height = 1;
}
message RequestEndBlock{
uint64 height = 1;
}
//----------------------------------------
// Response types
message Response {
MessageType type = 1;
bytes data = 2;
CodeType code = 3;
string error = 4;
string log = 5;
repeated Validator validators = 6;
oneof responses{
ResponseException exception = 1;
ResponseEcho echo = 2;
ResponseFlush flush = 3;
ResponseInfo info = 4;
ResponseSetOption set_option = 5;
ResponseAppendTx append_tx = 6;
ResponseCheckTx check_tx = 7;
ResponseCommit commit = 8;
ResponseQuery query = 9;
ResponseInitChain init_chain = 10;
ResponseBeginBlock begin_block = 11;
ResponseEndBlock end_block = 12;
}
}
message ResponseException{
string error = 1;
}
message ResponseEcho {
string message = 1;
}
message ResponseFlush{
}
message ResponseInfo {
string info = 1;
}
message ResponseSetOption{
string log = 1;
}
message ResponseAppendTx{
CodeType code = 1;
bytes data = 2;
string log = 3;
}
message ResponseCheckTx{
CodeType code = 1;
bytes data = 2;
string log = 3;
}
message ResponseQuery{
CodeType code = 1;
bytes data = 2;
string log = 3;
}
message ResponseCommit{
CodeType code = 1;
bytes data = 2;
string log = 3;
}
message ResponseInitChain{
}
message ResponseBeginBlock{
}
message ResponseEndBlock{
repeated Validator diffs = 4;
}
//----------------------------------------


Loading…
Cancel
Save