diff --git a/client/grpc_client.go b/client/grpc_client.go index 3f568ac28..ec6dcdb71 100644 --- a/client/grpc_client.go +++ b/client/grpc_client.go @@ -50,11 +50,10 @@ RETRY_LOOP: if err != nil { if cli.mustConnect { return err - } else { - log.Warn(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) - time.Sleep(time.Second * 3) - continue RETRY_LOOP } + log.Warn(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) + time.Sleep(time.Second * 3) + continue RETRY_LOOP } client := types.NewABCIApplicationClient(conn) @@ -268,11 +267,10 @@ func (cli *grpcClient) InfoSync() (resInfo types.ResponseInfo, err error) { if err = cli.Error(); err != nil { return resInfo, err } - if resInfo_ := reqres.Response.GetInfo(); resInfo_ != nil { - return *resInfo_, nil - } else { - return resInfo, nil + if info := reqres.Response.GetInfo(); info != nil { + return *info, nil } + return resInfo, nil } func (cli *grpcClient) SetOptionSync(key string, value string) (res types.Result) { @@ -335,9 +333,8 @@ func (cli *grpcClient) EndBlockSync(height uint64) (resEndBlock types.ResponseEn if err := cli.Error(); err != nil { return resEndBlock, err } - if resEndBlock_ := reqres.Response.GetEndBlock(); resEndBlock_ != nil { - return *resEndBlock_, nil - } else { - return resEndBlock, nil + if blk := reqres.Response.GetEndBlock(); blk != nil { + return *blk, nil } + return resEndBlock, nil } diff --git a/client/socket_client.go b/client/socket_client.go index 2ed51ef42..a0def2352 100644 --- a/client/socket_client.go +++ b/client/socket_client.go @@ -69,11 +69,10 @@ RETRY_LOOP: if err != nil { if cli.mustConnect { return err - } else { - log.Warn(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr)) - time.Sleep(time.Second * 3) - continue RETRY_LOOP } + log.Warn(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr)) + time.Sleep(time.Second * 3) + continue RETRY_LOOP } cli.conn = conn @@ -82,7 +81,6 @@ RETRY_LOOP: return nil } - return nil // never happens } func (cli *socketClient) OnStop() { @@ -298,11 +296,10 @@ func (cli *socketClient) InfoSync() (resInfo types.ResponseInfo, err error) { if err := cli.Error(); err != nil { return resInfo, err } - if resInfo_ := reqres.Response.GetInfo(); resInfo_ != nil { - return *resInfo_, nil - } else { - return resInfo, nil + if info := reqres.Response.GetInfo(); info != nil { + return *info, nil } + return resInfo, nil } func (cli *socketClient) SetOptionSync(key string, value string) (res types.Result) { @@ -379,11 +376,10 @@ func (cli *socketClient) EndBlockSync(height uint64) (resEndBlock types.Response if err := cli.Error(); err != nil { return resEndBlock, err } - if resEndBlock_ := reqres.Response.GetEndBlock(); resEndBlock_ != nil { - return *resEndBlock_, nil - } else { - return resEndBlock, nil + if blk := reqres.Response.GetEndBlock(); blk != nil { + return *blk, nil } + return resEndBlock, nil } //---------------------------------------- diff --git a/example/chain_aware/chain_aware_app.go b/example/chain_aware/chain_aware_app.go index 92fdad3df..a9a23375a 100644 --- a/example/chain_aware/chain_aware_app.go +++ b/example/chain_aware/chain_aware_app.go @@ -64,12 +64,12 @@ func (app *ChainAwareApplication) Query(query []byte) types.Result { } func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) { - app.beginCount += 1 + app.beginCount++ return } func (app *ChainAwareApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock) { - app.endCount += 1 + app.endCount++ return } diff --git a/example/counter/counter.go b/example/counter/counter.go index 03861d0f7..00e71f389 100644 --- a/example/counter/counter.go +++ b/example/counter/counter.go @@ -40,7 +40,7 @@ func (app *CounterApplication) DeliverTx(tx []byte) types.Result { return types.ErrBadNonce.SetLog(fmt.Sprintf("Invalid nonce. Expected %v, got %v", app.txCount, txValue)) } } - app.txCount += 1 + app.txCount++ return types.OK } @@ -60,15 +60,13 @@ func (app *CounterApplication) CheckTx(tx []byte) types.Result { } func (app *CounterApplication) Commit() types.Result { - app.hashCount += 1 - + app.hashCount++ if app.txCount == 0 { return types.OK - } else { - hash := make([]byte, 8) - binary.BigEndian.PutUint64(hash, uint64(app.txCount)) - return types.NewResultOK(hash, "") } + hash := make([]byte, 8) + binary.BigEndian.PutUint64(hash, uint64(app.txCount)) + return types.NewResultOK(hash, "") } func (app *CounterApplication) Query(query []byte) types.Result { diff --git a/example/example_test.go b/example/example_test.go index f31b39744..b60fc2763 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -60,7 +60,7 @@ func testStream(t *testing.T, app types.Application) { // Process response switch r := res.Value.(type) { case *types.Response_DeliverTx: - counter += 1 + counter++ if r.DeliverTx.Code != types.CodeType_OK { t.Error("DeliverTx failed with ret_code", r.DeliverTx.Code) } @@ -135,7 +135,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) { if err != nil { t.Fatalf("Error in GRPC DeliverTx: %v", err.Error()) } - counter += 1 + counter++ if response.Code != types.CodeType_OK { t.Error("DeliverTx failed with ret_code", response.Code) } diff --git a/server/socket_server.go b/server/socket_server.go index 8fe445cdb..070fba8cb 100644 --- a/server/socket_server.go +++ b/server/socket_server.go @@ -72,7 +72,7 @@ func (s *SocketServer) addConn(conn net.Conn) int { defer s.connsMtx.Unlock() connID := s.nextConnID - s.nextConnID += 1 + s.nextConnID++ s.conns[connID] = conn return connID diff --git a/tests/benchmarks/parallel/parallel.go b/tests/benchmarks/parallel/parallel.go index 88d19f325..ac8d4e9e9 100644 --- a/tests/benchmarks/parallel/parallel.go +++ b/tests/benchmarks/parallel/parallel.go @@ -25,7 +25,7 @@ func main() { if err != nil { log.Fatal(err.Error()) } - counter += 1 + counter++ if counter%1000 == 0 { fmt.Println("Read", counter) } @@ -47,7 +47,7 @@ func main() { log.Fatal(err.Error()) } - counter += 1 + counter++ if counter%1000 == 0 { fmt.Println("Write", counter) } diff --git a/tests/benchmarks/simple/simple.go b/tests/benchmarks/simple/simple.go index bd97567da..75b669238 100644 --- a/tests/benchmarks/simple/simple.go +++ b/tests/benchmarks/simple/simple.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "errors" "fmt" "log" "net" @@ -27,7 +26,7 @@ func main() { if err != nil { log.Fatal(err.Error()) } - counter += 1 + counter++ if counter%1000 == 0 { fmt.Println(counter) } @@ -63,7 +62,7 @@ func makeRequest(conn net.Conn, req *types.Request) (*types.Response, error) { return nil, err } if _, ok := resFlush.Value.(*types.Response_Flush); !ok { - return nil, errors.New(fmt.Sprintf("Expected flush response but got something else: %v", reflect.TypeOf(resFlush))) + return nil, fmt.Errorf("Expected flush response but got something else: %v", reflect.TypeOf(resFlush)) } return res, nil