mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-01 21:06:11 +00:00
AppendTx -> DeliverTx
This commit is contained in:
@@ -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, "")
|
||||
}
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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]))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
|
||||
}()
|
||||
|
||||
@@ -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, "")
|
||||
}
|
||||
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user