Browse Source

AppendTx -> DeliverTx

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
80f377135b
28 changed files with 168 additions and 168 deletions
  1. +5
    -5
      README.md
  2. +2
    -2
      client/client.go
  3. +7
    -7
      client/grpc_client.go
  4. +6
    -6
      client/local_client.go
  5. +7
    -7
      client/socket_client.go
  6. +6
    -6
      cmd/tmsp-cli/tmsp-cli.go
  7. +1
    -1
      example/chain_aware/chain_aware_app.go
  8. +1
    -1
      example/counter/counter.go
  9. +1
    -1
      example/dummy/dummy.go
  10. +3
    -3
      example/dummy/dummy_test.go
  11. +2
    -2
      example/dummy/persistent_dummy.go
  12. +17
    -17
      example/example_test.go
  13. +1
    -1
      example/nil/nil_app.go
  14. +1
    -1
      example/python/app.py
  15. +2
    -2
      example/python/tmsp/msg.py
  16. +1
    -1
      example/python3/app.py
  17. +2
    -2
      example/python3/tmsp/msg.py
  18. +3
    -3
      server/socket_server.go
  19. +4
    -4
      tests/test_app/app.go
  20. +8
    -8
      tests/test_app/main.go
  21. +2
    -2
      tests/test_cli/ex1.tmsp
  22. +2
    -2
      tests/test_cli/ex1.tmsp.out
  23. +3
    -3
      tests/test_cli/ex2.tmsp
  24. +3
    -3
      tests/test_cli/ex2.tmsp.out
  25. +5
    -5
      types/application.go
  26. +4
    -4
      types/messages.go
  27. +63
    -63
      types/types.pb.go
  28. +6
    -6
      types/types.proto

+ 5
- 5
README.md View File

@ -50,7 +50,7 @@ Note this prefixing does not apply for grpc.
TMSP requests/responses are simple Protobuf messages. Check out the [schema file](https://github.com/tendermint/tmsp/blob/master/types/types.proto).
#### AppendTx
#### DeliverTx
* __Arguments__:
* `Data ([]byte)`: The request transaction bytes
* __Returns__:
@ -71,7 +71,7 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
Validate a mempool transaction, prior to broadcasting or proposing. This message should not mutate the main state, but application
developers may want to keep a separate CheckTx state that gets reset upon Commit.
CheckTx can happen interspersed with AppendTx, but they happen on different connections - CheckTx from the mempool connection, and AppendTx from the consensus connection. During Commit, the mempool is locked, so you can reset the mempool state to the latest state after running all those appendtxs, and then the mempool will re run whatever txs it has against that latest mempool stte
CheckTx can happen interspersed with DeliverTx, but they happen on different connections - CheckTx from the mempool connection, and DeliverTx from the consensus connection. During Commit, the mempool is locked, so you can reset the mempool state to the latest state after running all those delivertxs, and then the mempool will re run whatever txs it has against that latest mempool stte
Transactions are first run through CheckTx before broadcast to peers in the mempool layer.
You can make CheckTx semi-stateful and clear the state upon `Commit` or `BeginBlock`,
@ -122,7 +122,7 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
* __Arguments__:
* `Height (uint64)`: The block height that is starting
* __Usage__:<br/>
Signals the beginning of a new block. Called prior to any AppendTxs.
Signals the beginning of a new block. Called prior to any DeliverTxs.
#### EndBlock
* __Arguments__:
@ -149,7 +149,7 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
##### Jan 23th, 2016
* Added CheckTx/Query TMSP message types
* Added Result/Log fields to AppendTx/CheckTx/SetOption
* Added Result/Log fields to DeliverTx/CheckTx/SetOption
* Removed Listener messages
* Removed Code from ResponseSetOption and ResponseGetHash
* Made examples BigEndian
@ -160,4 +160,4 @@ TMSP requests/responses are simple Protobuf messages. Check out the [schema fil
##### Jan 8th, 2016
* Tendermint/TMSP now comes to consensus on the order first before AppendTx.
* Tendermint/TMSP now comes to consensus on the order first before DeliverTx.

+ 2
- 2
client/client.go View File

@ -18,7 +18,7 @@ type Client interface {
EchoAsync(msg string) *ReqRes
InfoAsync() *ReqRes
SetOptionAsync(key string, value string) *ReqRes
AppendTxAsync(tx []byte) *ReqRes
DeliverTxAsync(tx []byte) *ReqRes
CheckTxAsync(tx []byte) *ReqRes
QueryAsync(tx []byte) *ReqRes
CommitAsync() *ReqRes
@ -27,7 +27,7 @@ type Client interface {
EchoSync(msg string) (res types.Result)
InfoSync() (resInfo types.ResponseInfo, err error)
SetOptionSync(key string, value string) (res types.Result)
AppendTxSync(tx []byte) (res types.Result)
DeliverTxSync(tx []byte) (res types.Result)
CheckTxSync(tx []byte) (res types.Result)
QuerySync(tx []byte) (res types.Result)
CommitSync() (res types.Result)


+ 7
- 7
client/grpc_client.go View File

@ -155,13 +155,13 @@ func (cli *grpcClient) SetOptionAsync(key string, value string) *ReqRes {
return cli.finishAsyncCall(req, &types.Response{&types.Response_SetOption{res}})
}
func (cli *grpcClient) AppendTxAsync(tx []byte) *ReqRes {
req := types.ToRequestAppendTx(tx)
res, err := cli.client.AppendTx(context.Background(), req.GetAppendTx(), grpc.FailFast(true))
func (cli *grpcClient) DeliverTxAsync(tx []byte) *ReqRes {
req := types.ToRequestDeliverTx(tx)
res, err := cli.client.DeliverTx(context.Background(), req.GetDeliverTx(), grpc.FailFast(true))
if err != nil {
cli.StopForError(err)
}
return cli.finishAsyncCall(req, &types.Response{&types.Response_AppendTx{res}})
return cli.finishAsyncCall(req, &types.Response{&types.Response_DeliverTx{res}})
}
func (cli *grpcClient) CheckTxAsync(tx []byte) *ReqRes {
@ -283,12 +283,12 @@ func (cli *grpcClient) SetOptionSync(key string, value string) (res types.Result
return types.Result{Code: OK, Data: nil, Log: resp.Log}
}
func (cli *grpcClient) AppendTxSync(tx []byte) (res types.Result) {
reqres := cli.AppendTxAsync(tx)
func (cli *grpcClient) DeliverTxSync(tx []byte) (res types.Result) {
reqres := cli.DeliverTxAsync(tx)
if res := cli.checkErrGetResult(); res.IsErr() {
return res
}
resp := reqres.Response.GetAppendTx()
resp := reqres.Response.GetDeliverTx()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}


+ 6
- 6
client/local_client.go View File

@ -69,13 +69,13 @@ func (app *localClient) SetOptionAsync(key string, value string) *ReqRes {
)
}
func (app *localClient) AppendTxAsync(tx []byte) *ReqRes {
func (app *localClient) DeliverTxAsync(tx []byte) *ReqRes {
app.mtx.Lock()
res := app.Application.AppendTx(tx)
res := app.Application.DeliverTx(tx)
app.mtx.Unlock()
return app.callback(
types.ToRequestAppendTx(tx),
types.ToResponseAppendTx(res.Code, res.Data, res.Log),
types.ToRequestDeliverTx(tx),
types.ToResponseDeliverTx(res.Code, res.Data, res.Log),
)
}
@ -171,9 +171,9 @@ func (app *localClient) SetOptionSync(key string, value string) (res types.Resul
return types.OK.SetLog(log)
}
func (app *localClient) AppendTxSync(tx []byte) (res types.Result) {
func (app *localClient) DeliverTxSync(tx []byte) (res types.Result) {
app.mtx.Lock()
res = app.Application.AppendTx(tx)
res = app.Application.DeliverTx(tx)
app.mtx.Unlock()
return res
}


+ 7
- 7
client/socket_client.go View File

@ -243,8 +243,8 @@ func (cli *socketClient) SetOptionAsync(key string, value string) *ReqRes {
return cli.queueRequest(types.ToRequestSetOption(key, value))
}
func (cli *socketClient) AppendTxAsync(tx []byte) *ReqRes {
return cli.queueRequest(types.ToRequestAppendTx(tx))
func (cli *socketClient) DeliverTxAsync(tx []byte) *ReqRes {
return cli.queueRequest(types.ToRequestDeliverTx(tx))
}
func (cli *socketClient) CheckTxAsync(tx []byte) *ReqRes {
@ -315,13 +315,13 @@ func (cli *socketClient) SetOptionSync(key string, value string) (res types.Resu
return types.Result{Code: OK, Data: nil, Log: resp.Log}
}
func (cli *socketClient) AppendTxSync(tx []byte) (res types.Result) {
reqres := cli.queueRequest(types.ToRequestAppendTx(tx))
func (cli *socketClient) DeliverTxSync(tx []byte) (res types.Result) {
reqres := cli.queueRequest(types.ToRequestDeliverTx(tx))
cli.FlushSync()
if err := cli.Error(); err != nil {
return types.ErrInternalError.SetLog(err.Error())
}
resp := reqres.Response.GetAppendTx()
resp := reqres.Response.GetDeliverTx()
return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
@ -429,8 +429,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
_, ok = res.Value.(*types.Response_Info)
case *types.Request_SetOption:
_, ok = res.Value.(*types.Response_SetOption)
case *types.Request_AppendTx:
_, ok = res.Value.(*types.Response_AppendTx)
case *types.Request_DeliverTx:
_, ok = res.Value.(*types.Response_DeliverTx)
case *types.Request_CheckTx:
_, ok = res.Value.(*types.Response_CheckTx)
case *types.Request_Commit:


+ 6
- 6
cmd/tmsp-cli/tmsp-cli.go View File

@ -104,10 +104,10 @@ func main() {
},
},
{
Name: "append_tx",
Usage: "Append a new tx to application",
Name: "deliver_tx",
Usage: "Deliver a new tx to application",
Action: func(c *cli.Context) error {
return cmdAppendTx(c)
return cmdDeliverTx(c)
},
},
{
@ -250,16 +250,16 @@ func cmdSetOption(c *cli.Context) error {
}
// Append a new tx to application
func cmdAppendTx(c *cli.Context) error {
func cmdDeliverTx(c *cli.Context) error {
args := c.Args()
if len(args) != 1 {
return errors.New("Command append_tx takes 1 argument")
return errors.New("Command deliver_tx takes 1 argument")
}
txBytes, err := stringOrHexToBytes(c.Args()[0])
if err != nil {
return err
}
res := client.AppendTxSync(txBytes)
res := client.DeliverTxSync(txBytes)
rsp := newResponse(res, string(res.Data), true)
printResponse(c, rsp)
return nil


+ 1
- 1
example/chain_aware/chain_aware_app.go View File

@ -45,7 +45,7 @@ func (app *ChainAwareApplication) SetOption(key string, value string) (log strin
return ""
}
func (app *ChainAwareApplication) AppendTx(tx []byte) types.Result {
func (app *ChainAwareApplication) DeliverTx(tx []byte) types.Result {
return types.NewResultOK(nil, "")
}


+ 1
- 1
example/counter/counter.go View File

@ -28,7 +28,7 @@ func (app *CounterApplication) SetOption(key string, value string) (log string)
return ""
}
func (app *CounterApplication) AppendTx(tx []byte) types.Result {
func (app *CounterApplication) DeliverTx(tx []byte) types.Result {
if app.serial {
if len(tx) > 8 {
return types.ErrEncodingError.SetLog(Fmt("Max tx size is 8 bytes, got %d", len(tx)))


+ 1
- 1
example/dummy/dummy.go View File

@ -28,7 +28,7 @@ func (app *DummyApplication) SetOption(key string, value string) (log string) {
}
// tx is either "key=value" or just arbitrary bytes
func (app *DummyApplication) AppendTx(tx []byte) types.Result {
func (app *DummyApplication) DeliverTx(tx []byte) types.Result {
parts := strings.Split(string(tx), "=")
if len(parts) == 2 {
app.state.Set([]byte(parts[0]), []byte(parts[1]))


+ 3
- 3
example/dummy/dummy_test.go View File

@ -13,10 +13,10 @@ import (
)
func testDummy(t *testing.T, dummy types.Application, tx []byte, key, value string) {
if r := dummy.AppendTx(tx); r.IsErr() {
if r := dummy.DeliverTx(tx); r.IsErr() {
t.Fatal(r)
}
if r := dummy.AppendTx(tx); r.IsErr() {
if r := dummy.DeliverTx(tx); r.IsErr() {
t.Fatal(r)
}
@ -175,7 +175,7 @@ func makeApplyBlock(t *testing.T, dummy types.Application, heightInt int, diff [
dummyChain := dummy.(types.BlockchainAware) // hmm...
dummyChain.BeginBlock(hash, header)
for _, tx := range txs {
if r := dummy.AppendTx(tx); r.IsErr() {
if r := dummy.DeliverTx(tx); r.IsErr() {
t.Fatal(r)
}
}


+ 2
- 2
example/dummy/persistent_dummy.go View File

@ -59,7 +59,7 @@ func (app *PersistentDummyApplication) SetOption(key string, value string) (log
}
// tx is either "key=value" or just arbitrary bytes
func (app *PersistentDummyApplication) AppendTx(tx []byte) types.Result {
func (app *PersistentDummyApplication) DeliverTx(tx []byte) types.Result {
// if it starts with "val:", update the validator set
// format is "val:pubkey/power"
if isValidatorTx(tx) {
@ -69,7 +69,7 @@ func (app *PersistentDummyApplication) AppendTx(tx []byte) types.Result {
}
// otherwise, update the key-value store
return app.app.AppendTx(tx)
return app.app.DeliverTx(tx)
}
func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result {


+ 17
- 17
example/example_test.go View File

@ -35,7 +35,7 @@ func TestGRPC(t *testing.T) {
func testStream(t *testing.T, app types.Application) {
numAppendTxs := 200000
numDeliverTxs := 200000
// Start the listener
server, err := server.NewSocketServer("unix://test.sock", app)
@ -57,15 +57,15 @@ func testStream(t *testing.T, app types.Application) {
client.SetResponseCallback(func(req *types.Request, res *types.Response) {
// Process response
switch r := res.Value.(type) {
case *types.Response_AppendTx:
case *types.Response_DeliverTx:
counter += 1
if r.AppendTx.Code != types.CodeType_OK {
t.Error("AppendTx failed with ret_code", r.AppendTx.Code)
if r.DeliverTx.Code != types.CodeType_OK {
t.Error("DeliverTx failed with ret_code", r.DeliverTx.Code)
}
if counter > numAppendTxs {
t.Fatalf("Too many AppendTx responses. Got %d, expected %d", counter, numAppendTxs)
if counter > numDeliverTxs {
t.Fatalf("Too many DeliverTx responses. Got %d, expected %d", counter, numDeliverTxs)
}
if counter == numAppendTxs {
if counter == numDeliverTxs {
go func() {
time.Sleep(time.Second * 2) // Wait for a bit to allow counter overflow
close(done)
@ -80,9 +80,9 @@ func testStream(t *testing.T, app types.Application) {
})
// Write requests
for counter := 0; counter < numAppendTxs; counter++ {
for counter := 0; counter < numDeliverTxs; counter++ {
// Send request
reqRes := client.AppendTxAsync([]byte("test"))
reqRes := client.DeliverTxAsync([]byte("test"))
_ = reqRes
// check err ?
@ -108,7 +108,7 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
numAppendTxs := 2000
numDeliverTxs := 2000
// Start the listener
server, err := server.NewGRPCServer("unix://test.sock", app)
@ -127,21 +127,21 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
client := types.NewTMSPApplicationClient(conn)
// Write requests
for counter := 0; counter < numAppendTxs; counter++ {
for counter := 0; counter < numDeliverTxs; counter++ {
// Send request
response, err := client.AppendTx(context.Background(), &types.RequestAppendTx{[]byte("test")})
response, err := client.DeliverTx(context.Background(), &types.RequestDeliverTx{[]byte("test")})
if err != nil {
t.Fatalf("Error in GRPC AppendTx: %v", err.Error())
t.Fatalf("Error in GRPC DeliverTx: %v", err.Error())
}
counter += 1
if response.Code != types.CodeType_OK {
t.Error("AppendTx failed with ret_code", response.Code)
t.Error("DeliverTx failed with ret_code", response.Code)
}
if counter > numAppendTxs {
t.Fatal("Too many AppendTx responses")
if counter > numDeliverTxs {
t.Fatal("Too many DeliverTx responses")
}
t.Log("response", counter)
if counter == numAppendTxs {
if counter == numDeliverTxs {
go func() {
time.Sleep(time.Second * 2) // Wait for a bit to allow counter overflow
}()


+ 1
- 1
example/nil/nil_app.go View File

@ -19,7 +19,7 @@ func (app *NilApplication) SetOption(key string, value string) (log string) {
return ""
}
func (app *NilApplication) AppendTx(tx []byte) types.Result {
func (app *NilApplication) DeliverTx(tx []byte) types.Result {
return types.NewResultOK(nil, "")
}


+ 1
- 1
example/python/app.py View File

@ -24,7 +24,7 @@ class CounterApplication():
self.serial = True
return 0
def append_tx(self, txBytes):
def deliver_tx(self, txBytes):
if self.serial:
txByteArray = bytearray(txBytes)
if len(txBytes) >= 2 and txBytes[:2] == "0x":


+ 2
- 2
example/python/tmsp/msg.py View File

@ -6,7 +6,7 @@ message_types = {
0x02: "flush",
0x03: "info",
0x04: "set_option",
0x21: "append_tx",
0x21: "deliver_tx",
0x22: "check_tx",
0x23: "commit",
0x24: "add_listener",
@ -32,7 +32,7 @@ class RequestDecoder():
def set_option(self):
return decode_string(self.reader), decode_string(self.reader)
def append_tx(self):
def deliver_tx(self):
return decode_string(self.reader)
def check_tx(self):


+ 1
- 1
example/python3/app.py View File

@ -24,7 +24,7 @@ class CounterApplication():
self.serial = True
return 0
def append_tx(self, txBytes):
def deliver_tx(self, txBytes):
if self.serial:
txByteArray = bytearray(txBytes)
if len(txBytes) >= 2 and txBytes[:2] == "0x":


+ 2
- 2
example/python3/tmsp/msg.py View File

@ -6,7 +6,7 @@ message_types = {
0x02: "flush",
0x03: "info",
0x04: "set_option",
0x21: "append_tx",
0x21: "deliver_tx",
0x22: "check_tx",
0x23: "commit",
0x24: "add_listener",
@ -32,7 +32,7 @@ class RequestDecoder():
def set_option(self):
return decode_string(self.reader), decode_string(self.reader)
def append_tx(self):
def deliver_tx(self):
return decode_string(self.reader)
def check_tx(self):


+ 3
- 3
server/socket_server.go View File

@ -174,9 +174,9 @@ func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types
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_DeliverTx:
res := s.app.DeliverTx(r.DeliverTx.Tx)
responses <- types.ToResponseDeliverTx(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)


+ 4
- 4
tests/test_app/app.go View File

@ -62,15 +62,15 @@ func Commit(client tmspcli.Client, hashExp []byte) {
}
}
func AppendTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.AppendTxSync(txBytes)
func DeliverTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.DeliverTxSync(txBytes)
code, data, log := res.Code, res.Data, res.Log
if code != codeExp {
panic(Fmt("AppendTx response code was unexpected. Got %v expected %v. Log: %v",
panic(Fmt("DeliverTx response code was unexpected. Got %v expected %v. Log: %v",
code, codeExp, log))
}
if !bytes.Equal(data, dataExp) {
panic(Fmt("AppendTx response data was unexpected. Got %X expected %X",
panic(Fmt("DeliverTx response data was unexpected. Got %X expected %X",
data, dataExp))
}
}


+ 8
- 8
tests/test_app/main.go View File

@ -34,15 +34,15 @@ func testCounter() {
SetOption(client, "serial", "on")
Commit(client, nil)
AppendTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
DeliverTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
Commit(client, nil)
AppendTx(client, []byte{0x00}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00}, types.CodeType_OK, nil)
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1})
AppendTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
AppendTx(client, []byte{0x01}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
DeliverTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
DeliverTx(client, []byte{0x01}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5})
}

+ 2
- 2
tests/test_cli/ex1.tmsp View File

@ -1,10 +1,10 @@
echo hello
info
commit
append_tx "abc"
deliver_tx "abc"
info
commit
query "abc"
append_tx "def=xyz"
deliver_tx "def=xyz"
commit
query "def"

+ 2
- 2
tests/test_cli/ex1.tmsp.out View File

@ -7,7 +7,7 @@
> commit
-> data: 0x
> append_tx "abc"
> deliver_tx "abc"
-> code: OK
> info
@ -20,7 +20,7 @@
-> code: OK
-> data: {"index":0,"value":"abc","valueHex":"616263","exists":true}
> append_tx "def=xyz"
> deliver_tx "def=xyz"
-> code: OK
> commit


+ 3
- 3
tests/test_cli/ex2.tmsp View File

@ -1,8 +1,8 @@
set_option serial on
check_tx 0x00
check_tx 0xff
append_tx 0x00
deliver_tx 0x00
check_tx 0x00
append_tx 0x01
append_tx 0x04
deliver_tx 0x01
deliver_tx 0x04
info

+ 3
- 3
tests/test_cli/ex2.tmsp.out View File

@ -7,17 +7,17 @@
> check_tx 0xff
-> code: OK
> append_tx 0x00
> deliver_tx 0x00
-> code: OK
> check_tx 0x00
-> code: BadNonce
-> log: Invalid nonce. Expected >= 1, got 0
> append_tx 0x01
> deliver_tx 0x01
-> code: OK
> append_tx 0x04
> deliver_tx 0x04
-> code: BadNonce
-> log: Invalid nonce. Expected 2, got 4


+ 5
- 5
types/application.go View File

@ -13,8 +13,8 @@ type Application interface {
// Set application option (e.g. mode=mempool, mode=consensus)
SetOption(key string, value string) (log string)
// Append a tx
AppendTx(tx []byte) Result
// Deliver a tx
DeliverTx(tx []byte) Result
// Validate a tx for the mempool
CheckTx(tx []byte) Result
@ -67,9 +67,9 @@ func (app *GRPCApplication) SetOption(ctx context.Context, req *RequestSetOption
return &ResponseSetOption{app.app.SetOption(req.Key, req.Value)}, nil
}
func (app *GRPCApplication) AppendTx(ctx context.Context, req *RequestAppendTx) (*ResponseAppendTx, error) {
r := app.app.AppendTx(req.Tx)
return &ResponseAppendTx{r.Code, r.Data, r.Log}, nil
func (app *GRPCApplication) DeliverTx(ctx context.Context, req *RequestDeliverTx) (*ResponseDeliverTx, error) {
r := app.app.DeliverTx(req.Tx)
return &ResponseDeliverTx{r.Code, r.Data, r.Log}, nil
}
func (app *GRPCApplication) CheckTx(ctx context.Context, req *RequestCheckTx) (*ResponseCheckTx, error) {


+ 4
- 4
types/messages.go View File

@ -31,9 +31,9 @@ func ToRequestSetOption(key string, value string) *Request {
}
}
func ToRequestAppendTx(txBytes []byte) *Request {
func ToRequestDeliverTx(txBytes []byte) *Request {
return &Request{
Value: &Request_AppendTx{&RequestAppendTx{txBytes}},
Value: &Request_DeliverTx{&RequestDeliverTx{txBytes}},
}
}
@ -105,9 +105,9 @@ func ToResponseSetOption(log string) *Response {
}
}
func ToResponseAppendTx(code CodeType, data []byte, log string) *Response {
func ToResponseDeliverTx(code CodeType, data []byte, log string) *Response {
return &Response{
Value: &Response_AppendTx{&ResponseAppendTx{code, data, log}},
Value: &Response_DeliverTx{&ResponseDeliverTx{code, data, log}},
}
}


+ 63
- 63
types/types.pb.go View File

@ -14,7 +14,7 @@ It has these top-level messages:
RequestFlush
RequestInfo
RequestSetOption
RequestAppendTx
RequestDeliverTx
RequestCheckTx
RequestQuery
RequestCommit
@ -27,7 +27,7 @@ It has these top-level messages:
ResponseFlush
ResponseInfo
ResponseSetOption
ResponseAppendTx
ResponseDeliverTx
ResponseCheckTx
ResponseQuery
ResponseCommit
@ -74,7 +74,7 @@ const (
MessageType_Info MessageType = 3
MessageType_SetOption MessageType = 4
MessageType_Exception MessageType = 5
MessageType_AppendTx MessageType = 17
MessageType_DeliverTx MessageType = 17
MessageType_CheckTx MessageType = 18
MessageType_Commit MessageType = 19
MessageType_Query MessageType = 20
@ -90,7 +90,7 @@ var MessageType_name = map[int32]string{
3: "Info",
4: "SetOption",
5: "Exception",
17: "AppendTx",
17: "DeliverTx",
18: "CheckTx",
19: "Commit",
20: "Query",
@ -105,7 +105,7 @@ var MessageType_value = map[string]int32{
"Info": 3,
"SetOption": 4,
"Exception": 5,
"AppendTx": 17,
"DeliverTx": 17,
"CheckTx": 18,
"Commit": 19,
"Query": 20,
@ -233,7 +233,7 @@ type Request struct {
// *Request_Flush
// *Request_Info
// *Request_SetOption
// *Request_AppendTx
// *Request_DeliverTx
// *Request_CheckTx
// *Request_Commit
// *Request_Query
@ -264,8 +264,8 @@ type Request_Info struct {
type Request_SetOption struct {
SetOption *RequestSetOption `protobuf:"bytes,4,opt,name=set_option,json=setOption,oneof"`
}
type Request_AppendTx struct {
AppendTx *RequestAppendTx `protobuf:"bytes,5,opt,name=append_tx,json=appendTx,oneof"`
type Request_DeliverTx struct {
DeliverTx *RequestDeliverTx `protobuf:"bytes,5,opt,name=deliver_tx,json=deliverTx,oneof"`
}
type Request_CheckTx struct {
CheckTx *RequestCheckTx `protobuf:"bytes,6,opt,name=check_tx,json=checkTx,oneof"`
@ -290,7 +290,7 @@ func (*Request_Echo) isRequest_Value() {}
func (*Request_Flush) isRequest_Value() {}
func (*Request_Info) isRequest_Value() {}
func (*Request_SetOption) isRequest_Value() {}
func (*Request_AppendTx) isRequest_Value() {}
func (*Request_DeliverTx) isRequest_Value() {}
func (*Request_CheckTx) isRequest_Value() {}
func (*Request_Commit) isRequest_Value() {}
func (*Request_Query) isRequest_Value() {}
@ -333,9 +333,9 @@ func (m *Request) GetSetOption() *RequestSetOption {
return nil
}
func (m *Request) GetAppendTx() *RequestAppendTx {
if x, ok := m.GetValue().(*Request_AppendTx); ok {
return x.AppendTx
func (m *Request) GetDeliverTx() *RequestDeliverTx {
if x, ok := m.GetValue().(*Request_DeliverTx); ok {
return x.DeliverTx
}
return nil
}
@ -389,7 +389,7 @@ func (*Request) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error
(*Request_Flush)(nil),
(*Request_Info)(nil),
(*Request_SetOption)(nil),
(*Request_AppendTx)(nil),
(*Request_DeliverTx)(nil),
(*Request_CheckTx)(nil),
(*Request_Commit)(nil),
(*Request_Query)(nil),
@ -423,9 +423,9 @@ func _Request_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
if err := b.EncodeMessage(x.SetOption); err != nil {
return err
}
case *Request_AppendTx:
case *Request_DeliverTx:
b.EncodeVarint(5<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.AppendTx); err != nil {
if err := b.EncodeMessage(x.DeliverTx); err != nil {
return err
}
case *Request_CheckTx:
@ -500,13 +500,13 @@ func _Request_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer
err := b.DecodeMessage(msg)
m.Value = &Request_SetOption{msg}
return true, err
case 5: // value.append_tx
case 5: // value.deliver_tx
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(RequestAppendTx)
msg := new(RequestDeliverTx)
err := b.DecodeMessage(msg)
m.Value = &Request_AppendTx{msg}
m.Value = &Request_DeliverTx{msg}
return true, err
case 6: // value.check_tx
if wire != proto.WireBytes {
@ -585,8 +585,8 @@ func _Request_OneofSizer(msg proto.Message) (n int) {
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Request_AppendTx:
s := proto.Size(x.AppendTx)
case *Request_DeliverTx:
s := proto.Size(x.DeliverTx)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
@ -683,16 +683,16 @@ func (m *RequestSetOption) GetValue() string {
return ""
}
type RequestAppendTx struct {
type RequestDeliverTx struct {
Tx []byte `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"`
}
func (m *RequestAppendTx) Reset() { *m = RequestAppendTx{} }
func (m *RequestAppendTx) String() string { return proto.CompactTextString(m) }
func (*RequestAppendTx) ProtoMessage() {}
func (*RequestAppendTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *RequestDeliverTx) Reset() { *m = RequestDeliverTx{} }
func (m *RequestDeliverTx) String() string { return proto.CompactTextString(m) }
func (*RequestDeliverTx) ProtoMessage() {}
func (*RequestDeliverTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *RequestAppendTx) GetTx() []byte {
func (m *RequestDeliverTx) GetTx() []byte {
if m != nil {
return m.Tx
}
@ -802,7 +802,7 @@ type Response struct {
// *Response_Flush
// *Response_Info
// *Response_SetOption
// *Response_AppendTx
// *Response_DeliverTx
// *Response_CheckTx
// *Response_Commit
// *Response_Query
@ -836,8 +836,8 @@ type Response_Info struct {
type Response_SetOption struct {
SetOption *ResponseSetOption `protobuf:"bytes,5,opt,name=set_option,json=setOption,oneof"`
}
type Response_AppendTx struct {
AppendTx *ResponseAppendTx `protobuf:"bytes,6,opt,name=append_tx,json=appendTx,oneof"`
type Response_DeliverTx struct {
DeliverTx *ResponseDeliverTx `protobuf:"bytes,6,opt,name=deliver_tx,json=deliverTx,oneof"`
}
type Response_CheckTx struct {
CheckTx *ResponseCheckTx `protobuf:"bytes,7,opt,name=check_tx,json=checkTx,oneof"`
@ -863,7 +863,7 @@ func (*Response_Echo) isResponse_Value() {}
func (*Response_Flush) isResponse_Value() {}
func (*Response_Info) isResponse_Value() {}
func (*Response_SetOption) isResponse_Value() {}
func (*Response_AppendTx) isResponse_Value() {}
func (*Response_DeliverTx) isResponse_Value() {}
func (*Response_CheckTx) isResponse_Value() {}
func (*Response_Commit) isResponse_Value() {}
func (*Response_Query) isResponse_Value() {}
@ -913,9 +913,9 @@ func (m *Response) GetSetOption() *ResponseSetOption {
return nil
}
func (m *Response) GetAppendTx() *ResponseAppendTx {
if x, ok := m.GetValue().(*Response_AppendTx); ok {
return x.AppendTx
func (m *Response) GetDeliverTx() *ResponseDeliverTx {
if x, ok := m.GetValue().(*Response_DeliverTx); ok {
return x.DeliverTx
}
return nil
}
@ -970,7 +970,7 @@ func (*Response) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) erro
(*Response_Flush)(nil),
(*Response_Info)(nil),
(*Response_SetOption)(nil),
(*Response_AppendTx)(nil),
(*Response_DeliverTx)(nil),
(*Response_CheckTx)(nil),
(*Response_Commit)(nil),
(*Response_Query)(nil),
@ -1009,9 +1009,9 @@ func _Response_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
if err := b.EncodeMessage(x.SetOption); err != nil {
return err
}
case *Response_AppendTx:
case *Response_DeliverTx:
b.EncodeVarint(6<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.AppendTx); err != nil {
if err := b.EncodeMessage(x.DeliverTx); err != nil {
return err
}
case *Response_CheckTx:
@ -1094,13 +1094,13 @@ func _Response_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffe
err := b.DecodeMessage(msg)
m.Value = &Response_SetOption{msg}
return true, err
case 6: // value.append_tx
case 6: // value.deliver_tx
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ResponseAppendTx)
msg := new(ResponseDeliverTx)
err := b.DecodeMessage(msg)
m.Value = &Response_AppendTx{msg}
m.Value = &Response_DeliverTx{msg}
return true, err
case 7: // value.check_tx
if wire != proto.WireBytes {
@ -1184,8 +1184,8 @@ func _Response_OneofSizer(msg proto.Message) (n int) {
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Response_AppendTx:
s := proto.Size(x.AppendTx)
case *Response_DeliverTx:
s := proto.Size(x.DeliverTx)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
@ -1322,32 +1322,32 @@ func (m *ResponseSetOption) GetLog() string {
return ""
}
type ResponseAppendTx struct {
type ResponseDeliverTx struct {
Code CodeType `protobuf:"varint,1,opt,name=code,enum=types.CodeType" json:"code,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
Log string `protobuf:"bytes,3,opt,name=log" json:"log,omitempty"`
}
func (m *ResponseAppendTx) Reset() { *m = ResponseAppendTx{} }
func (m *ResponseAppendTx) String() string { return proto.CompactTextString(m) }
func (*ResponseAppendTx) ProtoMessage() {}
func (*ResponseAppendTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} }
func (m *ResponseDeliverTx) Reset() { *m = ResponseDeliverTx{} }
func (m *ResponseDeliverTx) String() string { return proto.CompactTextString(m) }
func (*ResponseDeliverTx) ProtoMessage() {}
func (*ResponseDeliverTx) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} }
func (m *ResponseAppendTx) GetCode() CodeType {
func (m *ResponseDeliverTx) GetCode() CodeType {
if m != nil {
return m.Code
}
return CodeType_OK
}
func (m *ResponseAppendTx) GetData() []byte {
func (m *ResponseDeliverTx) GetData() []byte {
if m != nil {
return m.Data
}
return nil
}
func (m *ResponseAppendTx) GetLog() string {
func (m *ResponseDeliverTx) GetLog() string {
if m != nil {
return m.Log
}
@ -1640,7 +1640,7 @@ func init() {
proto.RegisterType((*RequestFlush)(nil), "types.RequestFlush")
proto.RegisterType((*RequestInfo)(nil), "types.RequestInfo")
proto.RegisterType((*RequestSetOption)(nil), "types.RequestSetOption")
proto.RegisterType((*RequestAppendTx)(nil), "types.RequestAppendTx")
proto.RegisterType((*RequestDeliverTx)(nil), "types.RequestDeliverTx")
proto.RegisterType((*RequestCheckTx)(nil), "types.RequestCheckTx")
proto.RegisterType((*RequestQuery)(nil), "types.RequestQuery")
proto.RegisterType((*RequestCommit)(nil), "types.RequestCommit")
@ -1653,7 +1653,7 @@ func init() {
proto.RegisterType((*ResponseFlush)(nil), "types.ResponseFlush")
proto.RegisterType((*ResponseInfo)(nil), "types.ResponseInfo")
proto.RegisterType((*ResponseSetOption)(nil), "types.ResponseSetOption")
proto.RegisterType((*ResponseAppendTx)(nil), "types.ResponseAppendTx")
proto.RegisterType((*ResponseDeliverTx)(nil), "types.ResponseDeliverTx")
proto.RegisterType((*ResponseCheckTx)(nil), "types.ResponseCheckTx")
proto.RegisterType((*ResponseQuery)(nil), "types.ResponseQuery")
proto.RegisterType((*ResponseCommit)(nil), "types.ResponseCommit")
@ -1683,7 +1683,7 @@ type TMSPApplicationClient interface {
Flush(ctx context.Context, in *RequestFlush, opts ...grpc.CallOption) (*ResponseFlush, error)
Info(ctx context.Context, in *RequestInfo, opts ...grpc.CallOption) (*ResponseInfo, error)
SetOption(ctx context.Context, in *RequestSetOption, opts ...grpc.CallOption) (*ResponseSetOption, error)
AppendTx(ctx context.Context, in *RequestAppendTx, opts ...grpc.CallOption) (*ResponseAppendTx, error)
DeliverTx(ctx context.Context, in *RequestDeliverTx, opts ...grpc.CallOption) (*ResponseDeliverTx, error)
CheckTx(ctx context.Context, in *RequestCheckTx, opts ...grpc.CallOption) (*ResponseCheckTx, error)
Query(ctx context.Context, in *RequestQuery, opts ...grpc.CallOption) (*ResponseQuery, error)
Commit(ctx context.Context, in *RequestCommit, opts ...grpc.CallOption) (*ResponseCommit, error)
@ -1736,9 +1736,9 @@ func (c *tMSPApplicationClient) SetOption(ctx context.Context, in *RequestSetOpt
return out, nil
}
func (c *tMSPApplicationClient) AppendTx(ctx context.Context, in *RequestAppendTx, opts ...grpc.CallOption) (*ResponseAppendTx, error) {
out := new(ResponseAppendTx)
err := grpc.Invoke(ctx, "/types.TMSPApplication/AppendTx", in, out, c.cc, opts...)
func (c *tMSPApplicationClient) DeliverTx(ctx context.Context, in *RequestDeliverTx, opts ...grpc.CallOption) (*ResponseDeliverTx, error) {
out := new(ResponseDeliverTx)
err := grpc.Invoke(ctx, "/types.TMSPApplication/DeliverTx", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@ -1806,7 +1806,7 @@ type TMSPApplicationServer interface {
Flush(context.Context, *RequestFlush) (*ResponseFlush, error)
Info(context.Context, *RequestInfo) (*ResponseInfo, error)
SetOption(context.Context, *RequestSetOption) (*ResponseSetOption, error)
AppendTx(context.Context, *RequestAppendTx) (*ResponseAppendTx, error)
DeliverTx(context.Context, *RequestDeliverTx) (*ResponseDeliverTx, error)
CheckTx(context.Context, *RequestCheckTx) (*ResponseCheckTx, error)
Query(context.Context, *RequestQuery) (*ResponseQuery, error)
Commit(context.Context, *RequestCommit) (*ResponseCommit, error)
@ -1891,20 +1891,20 @@ func _TMSPApplication_SetOption_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _TMSPApplication_AppendTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RequestAppendTx)
func _TMSPApplication_DeliverTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RequestDeliverTx)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TMSPApplicationServer).AppendTx(ctx, in)
return srv.(TMSPApplicationServer).DeliverTx(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/types.TMSPApplication/AppendTx",
FullMethod: "/types.TMSPApplication/DeliverTx",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TMSPApplicationServer).AppendTx(ctx, req.(*RequestAppendTx))
return srv.(TMSPApplicationServer).DeliverTx(ctx, req.(*RequestDeliverTx))
}
return interceptor(ctx, in, info, handler)
}
@ -2038,8 +2038,8 @@ var _TMSPApplication_serviceDesc = grpc.ServiceDesc{
Handler: _TMSPApplication_SetOption_Handler,
},
{
MethodName: "AppendTx",
Handler: _TMSPApplication_AppendTx_Handler,
MethodName: "DeliverTx",
Handler: _TMSPApplication_DeliverTx_Handler,
},
{
MethodName: "CheckTx",


+ 6
- 6
types/types.proto View File

@ -18,7 +18,7 @@ enum MessageType {
Info = 0x03;
SetOption = 0x04;
Exception = 0x05;
AppendTx = 0x11;
DeliverTx = 0x11;
CheckTx = 0x12;
Commit = 0x13;
Query = 0x14;
@ -79,7 +79,7 @@ message Request {
RequestFlush flush = 2;
RequestInfo info = 3;
RequestSetOption set_option = 4;
RequestAppendTx append_tx = 5;
RequestDeliverTx deliver_tx = 5;
RequestCheckTx check_tx = 6;
RequestCommit commit = 7;
RequestQuery query = 8;
@ -104,7 +104,7 @@ message RequestSetOption{
string value = 2;
}
message RequestAppendTx{
message RequestDeliverTx{
bytes tx = 1;
}
@ -143,7 +143,7 @@ message Response {
ResponseFlush flush = 3;
ResponseInfo info = 4;
ResponseSetOption set_option = 5;
ResponseAppendTx append_tx = 6;
ResponseDeliverTx deliver_tx = 6;
ResponseCheckTx check_tx = 7;
ResponseCommit commit = 8;
ResponseQuery query = 9;
@ -175,7 +175,7 @@ message ResponseSetOption{
string log = 1;
}
message ResponseAppendTx{
message ResponseDeliverTx{
CodeType code = 1;
bytes data = 2;
string log = 3;
@ -248,7 +248,7 @@ service TMSPApplication {
rpc Flush(RequestFlush) returns (ResponseFlush);
rpc Info(RequestInfo) returns (ResponseInfo);
rpc SetOption(RequestSetOption) returns (ResponseSetOption);
rpc AppendTx(RequestAppendTx) returns (ResponseAppendTx);
rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx);
rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx);
rpc Query(RequestQuery) returns (ResponseQuery);
rpc Commit(RequestCommit) returns (ResponseCommit);


Loading…
Cancel
Save