From fcaa545e1ef4d68ae35dc064693da7df9b832204 Mon Sep 17 00:00:00 2001 From: Tzu-Jung Lee Date: Mon, 16 Jan 2017 22:48:24 -0800 Subject: [PATCH] lint: remove dot import (go-common) Spell out the package explicitly. This commit is totally textual, and does not change any logic. The swiss-army knife package may serve a kick-start in early stage development. But as the codebase growing, we might want to retire it gradually: For simple wrapping functions, just inline it on the call site. For larger pice of code, make it an independent package. --- client/client.go | 4 ++-- client/grpc_client.go | 12 ++++++------ client/local_client.go | 6 +++--- client/socket_client.go | 16 ++++++++-------- cmd/abci-cli/tmsp-cli.go | 10 +++++----- cmd/counter/main.go | 6 +++--- cmd/dummy/main.go | 6 +++--- example/chain_aware/chain_aware_app.go | 8 ++++---- example/chain_aware/chain_aware_test.go | 4 ++-- example/counter/counter.go | 18 +++++++++--------- example/dummy/dummy.go | 4 ++-- example/dummy/dummy_test.go | 6 +++--- example/dummy/persistent_dummy.go | 18 +++++++++--------- example/example_test.go | 13 +++++++------ server/grpc_server.go | 8 ++++---- server/server.go | 6 +++--- server/socket_server.go | 10 +++++----- tests/benchmarks/parallel/parallel.go | 13 ++++++------- tests/benchmarks/simple/simple.go | 11 +++++------ tests/test_app/app.go | 18 +++++++++--------- 20 files changed, 98 insertions(+), 99 deletions(-) diff --git a/client/client.go b/client/client.go index cdeb4db0f..dc70645e4 100644 --- a/client/client.go +++ b/client/client.go @@ -5,11 +5,11 @@ import ( "sync" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) type Client interface { - Service + common.Service SetResponseCallback(Callback) Error() error diff --git a/client/grpc_client.go b/client/grpc_client.go index 1a0e11d2e..c48ebbcb5 100644 --- a/client/grpc_client.go +++ b/client/grpc_client.go @@ -9,13 +9,13 @@ import ( grpc "google.golang.org/grpc" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) // A stripped copy of the remoteClient that makes // synchronous calls using grpc type grpcClient struct { - BaseService + common.BaseService mustConnect bool client types.ABCIApplicationClient @@ -31,13 +31,13 @@ func NewGRPCClient(addr string, mustConnect bool) (*grpcClient, error) { addr: addr, mustConnect: mustConnect, } - cli.BaseService = *NewBaseService(nil, "grpcClient", cli) + cli.BaseService = *common.NewBaseService(nil, "grpcClient", cli) _, err := cli.Start() // Just start it, it's confusing for callers to remember to start. return cli, err } func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) { - return Connect(addr) + return common.Connect(addr) } func (cli *grpcClient) OnStart() error { @@ -50,7 +50,7 @@ RETRY_LOOP: if cli.mustConnect { return err } else { - log.Warn(Fmt("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) + log.Warn(common.Fmt("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr)) time.Sleep(time.Second * 3) continue RETRY_LOOP } @@ -93,7 +93,7 @@ func (cli *grpcClient) StopForError(err error) { } cli.mtx.Unlock() - log.Warn(Fmt("Stopping abci.grpcClient for error: %v", err.Error())) + log.Warn(common.Fmt("Stopping abci.grpcClient for error: %v", err.Error())) cli.Stop() } diff --git a/client/local_client.go b/client/local_client.go index 33dd619be..235e3fce8 100644 --- a/client/local_client.go +++ b/client/local_client.go @@ -4,11 +4,11 @@ import ( "sync" types "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) type localClient struct { - BaseService + common.BaseService mtx *sync.Mutex types.Application Callback @@ -22,7 +22,7 @@ func NewLocalClient(mtx *sync.Mutex, app types.Application) *localClient { mtx: mtx, Application: app, } - cli.BaseService = *NewBaseService(log, "localClient", cli) + cli.BaseService = *common.NewBaseService(log, "localClient", cli) return cli } diff --git a/client/socket_client.go b/client/socket_client.go index 744b6c0c8..9309b67ad 100644 --- a/client/socket_client.go +++ b/client/socket_client.go @@ -11,7 +11,7 @@ import ( "time" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) const ( @@ -27,10 +27,10 @@ const flushThrottleMS = 20 // Don't wait longer than... // the application in general is not meant to be interfaced // with concurrent callers. type socketClient struct { - BaseService + common.BaseService reqQueue chan *ReqRes - flushTimer *ThrottleTimer + flushTimer *common.ThrottleTimer mustConnect bool mtx sync.Mutex @@ -45,14 +45,14 @@ type socketClient struct { func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) { cli := &socketClient{ reqQueue: make(chan *ReqRes, reqQueueSize), - flushTimer: NewThrottleTimer("socketClient", flushThrottleMS), + flushTimer: common.NewThrottleTimer("socketClient", flushThrottleMS), mustConnect: mustConnect, addr: addr, reqSent: list.New(), resCb: nil, } - cli.BaseService = *NewBaseService(nil, "socketClient", cli) + cli.BaseService = *common.NewBaseService(nil, "socketClient", cli) _, err := cli.Start() // Just start it, it's confusing for callers to remember to start. return cli, err @@ -65,12 +65,12 @@ func (cli *socketClient) OnStart() error { var conn net.Conn RETRY_LOOP: for { - conn, err = Connect(cli.addr) + conn, err = common.Connect(cli.addr) if err != nil { if cli.mustConnect { return err } else { - log.Warn(Fmt("abci.socketClient failed to connect to %v. Retrying...", cli.addr)) + log.Warn(common.Fmt("abci.socketClient failed to connect to %v. Retrying...", cli.addr)) time.Sleep(time.Second * 3) continue RETRY_LOOP } @@ -109,7 +109,7 @@ func (cli *socketClient) StopForError(err error) { } cli.mtx.Unlock() - log.Warn(Fmt("Stopping abci.socketClient for error: %v", err.Error())) + log.Warn(common.Fmt("Stopping abci.socketClient for error: %v", err.Error())) cli.Stop() } diff --git a/cmd/abci-cli/tmsp-cli.go b/cmd/abci-cli/tmsp-cli.go index 39dace9f9..99d22a086 100644 --- a/cmd/abci-cli/tmsp-cli.go +++ b/cmd/abci-cli/tmsp-cli.go @@ -11,7 +11,7 @@ import ( "github.com/tendermint/abci/client" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" "github.com/urfave/cli" ) @@ -135,7 +135,7 @@ func main() { app.Before = before err := app.Run(os.Args) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } } @@ -145,7 +145,7 @@ func before(c *cli.Context) error { var err error client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } } return nil @@ -244,7 +244,7 @@ func cmdSetOption(c *cli.Context) error { return errors.New("Command set_option takes 2 arguments (key, value)") } res := client.SetOptionSync(args[0], args[1]) - rsp := newResponse(res, Fmt("%s=%s", args[0], args[1]), false) + rsp := newResponse(res, common.Fmt("%s=%s", args[0], args[1]), false) printResponse(c, rsp) return nil } @@ -284,7 +284,7 @@ func cmdCheckTx(c *cli.Context) error { // Get application Merkle root hash func cmdCommit(c *cli.Context) error { res := client.CommitSync() - rsp := newResponse(res, Fmt("0x%X", res.Data), false) + rsp := newResponse(res, common.Fmt("0x%X", res.Data), false) printResponse(c, rsp) return nil } diff --git a/cmd/counter/main.go b/cmd/counter/main.go index 0714380b4..24abc5deb 100644 --- a/cmd/counter/main.go +++ b/cmd/counter/main.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/abci/example/counter" "github.com/tendermint/abci/server" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func main() { @@ -19,11 +19,11 @@ func main() { // Start the listener srv, err := server.NewServer(*addrPtr, *abciPtr, app) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } // Wait forever - TrapSignal(func() { + common.TrapSignal(func() { // Cleanup srv.Stop() }) diff --git a/cmd/dummy/main.go b/cmd/dummy/main.go index 8167c3541..503cf73bc 100644 --- a/cmd/dummy/main.go +++ b/cmd/dummy/main.go @@ -6,7 +6,7 @@ import ( "github.com/tendermint/abci/example/dummy" "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func main() { @@ -27,11 +27,11 @@ func main() { // Start the listener srv, err := server.NewServer(*addrPtr, *abciPtr, app) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } // Wait forever - TrapSignal(func() { + common.TrapSignal(func() { // Cleanup srv.Stop() }) diff --git a/example/chain_aware/chain_aware_app.go b/example/chain_aware/chain_aware_app.go index 85ea7129d..c0dc0d6e0 100644 --- a/example/chain_aware/chain_aware_app.go +++ b/example/chain_aware/chain_aware_app.go @@ -5,7 +5,7 @@ import ( "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func main() { @@ -17,11 +17,11 @@ func main() { // Start the listener srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication()) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } // Wait forever - TrapSignal(func() { + common.TrapSignal(func() { // Cleanup srv.Stop() }) @@ -58,7 +58,7 @@ func (app *ChainAwareApplication) Commit() types.Result { } func (app *ChainAwareApplication) Query(query []byte) types.Result { - return types.NewResultOK([]byte(Fmt("%d,%d", app.beginCount, app.endCount)), "") + return types.NewResultOK([]byte(common.Fmt("%d,%d", app.beginCount, app.endCount)), "") } func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) { diff --git a/example/chain_aware/chain_aware_test.go b/example/chain_aware/chain_aware_test.go index 942c9ba9c..a19dd781a 100644 --- a/example/chain_aware/chain_aware_test.go +++ b/example/chain_aware/chain_aware_test.go @@ -8,7 +8,7 @@ import ( "github.com/tendermint/abci/client" "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func TestChainAware(t *testing.T) { @@ -25,7 +25,7 @@ func TestChainAware(t *testing.T) { // Connect to the socket client, err := abcicli.NewSocketClient("unix://test.sock", false) if err != nil { - Exit(Fmt("Error starting socket client: %v", err.Error())) + common.Exit(Fmt("Error starting socket client: %v", err.Error())) } client.Start() defer client.Stop() diff --git a/example/counter/counter.go b/example/counter/counter.go index 1249f667a..02ff00ee9 100644 --- a/example/counter/counter.go +++ b/example/counter/counter.go @@ -4,7 +4,7 @@ import ( "encoding/binary" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) type CounterApplication struct { @@ -18,7 +18,7 @@ func NewCounterApplication(serial bool) *CounterApplication { } func (app *CounterApplication) Info() types.ResponseInfo { - return types.ResponseInfo{Data: Fmt("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)} + return types.ResponseInfo{Data: common.Fmt("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)} } func (app *CounterApplication) SetOption(key string, value string) (log string) { @@ -31,13 +31,13 @@ func (app *CounterApplication) SetOption(key string, value string) (log string) 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))) + return types.ErrEncodingError.SetLog(common.Fmt("Max tx size is 8 bytes, got %d", len(tx))) } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8) if txValue != uint64(app.txCount) { - return types.ErrBadNonce.SetLog(Fmt("Invalid nonce. Expected %v, got %v", app.txCount, txValue)) + return types.ErrBadNonce.SetLog(common.Fmt("Invalid nonce. Expected %v, got %v", app.txCount, txValue)) } } app.txCount += 1 @@ -47,13 +47,13 @@ func (app *CounterApplication) DeliverTx(tx []byte) types.Result { func (app *CounterApplication) CheckTx(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))) + return types.ErrEncodingError.SetLog(common.Fmt("Max tx size is 8 bytes, got %d", len(tx))) } tx8 := make([]byte, 8) copy(tx8[len(tx8)-len(tx):], tx) txValue := binary.BigEndian.Uint64(tx8) if txValue < uint64(app.txCount) { - return types.ErrBadNonce.SetLog(Fmt("Invalid nonce. Expected >= %v, got %v", app.txCount, txValue)) + return types.ErrBadNonce.SetLog(common.Fmt("Invalid nonce. Expected >= %v, got %v", app.txCount, txValue)) } } return types.OK @@ -76,10 +76,10 @@ func (app *CounterApplication) Query(query []byte) types.Result { switch queryStr { case "hash": - return types.NewResultOK(nil, Fmt("%v", app.hashCount)) + return types.NewResultOK(nil, common.Fmt("%v", app.hashCount)) case "tx": - return types.NewResultOK(nil, Fmt("%v", app.txCount)) + return types.NewResultOK(nil, common.Fmt("%v", app.txCount)) } - return types.ErrUnknownRequest.SetLog(Fmt("Invalid nonce. Expected hash or tx, got %v", queryStr)) + return types.ErrUnknownRequest.SetLog(common.Fmt("Invalid nonce. Expected hash or tx, got %v", queryStr)) } diff --git a/example/dummy/dummy.go b/example/dummy/dummy.go index 6fdf87859..c49353e1b 100644 --- a/example/dummy/dummy.go +++ b/example/dummy/dummy.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" "github.com/tendermint/go-merkle" "github.com/tendermint/go-wire" ) @@ -20,7 +20,7 @@ func NewDummyApplication() *DummyApplication { } func (app *DummyApplication) Info() (resInfo types.ResponseInfo) { - return types.ResponseInfo{Data: Fmt("{\"size\":%v}", app.state.Size())} + return types.ResponseInfo{Data: common.Fmt("{\"size\":%v}", app.state.Size())} } func (app *DummyApplication) SetOption(key string, value string) (log string) { diff --git a/example/dummy/dummy_test.go b/example/dummy/dummy_test.go index f745d2ead..9236068e8 100644 --- a/example/dummy/dummy_test.go +++ b/example/dummy/dummy_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire" ) @@ -107,8 +107,8 @@ func TestValSetChanges(t *testing.T) { nInit := 5 vals := make([]*types.Validator, total) for i := 0; i < total; i++ { - pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(Fmt("test%d", i))).PubKey().Bytes() - power := RandInt() + pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(common.Fmt("test%d", i))).PubKey().Bytes() + power := common.RandInt() vals[i] = &types.Validator{pubkey, uint64(power)} } // iniitalize with the first nInit diff --git a/example/dummy/persistent_dummy.go b/example/dummy/persistent_dummy.go index 550c5969f..b7c1eb4bb 100644 --- a/example/dummy/persistent_dummy.go +++ b/example/dummy/persistent_dummy.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" dbm "github.com/tendermint/go-db" "github.com/tendermint/go-merkle" "github.com/tendermint/go-wire" @@ -135,7 +135,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) { wire.ReadBinaryPtr(&lastBlock, r, 0, n, err) if *err != nil { // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED - Exit(Fmt("Data has been corrupted or its spec has changed: %v\n", *err)) + common.Exit(common.Fmt("Data has been corrupted or its spec has changed: %v\n", *err)) } // TODO: ensure that buf is completely read. } @@ -149,7 +149,7 @@ func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) { wire.WriteBinary(lastBlock, buf, n, err) if *err != nil { // TODO - PanicCrisis(*err) + common.PanicCrisis(*err) } db.Set(lastBlockKey, buf.Bytes()) } @@ -173,7 +173,7 @@ func (app *PersistentDummyApplication) Validators() (validators []*types.Validat } func MakeValSetChangeTx(pubkey []byte, power uint64) []byte { - return []byte(Fmt("val:%X/%d", pubkey, power)) + return []byte(common.Fmt("val:%X/%d", pubkey, power)) } func isValidatorTx(tx []byte) bool { @@ -188,16 +188,16 @@ func (app *PersistentDummyApplication) execValidatorTx(tx []byte) types.Result { tx = tx[len(ValidatorSetChangePrefix):] pubKeyAndPower := strings.Split(string(tx), "/") if len(pubKeyAndPower) != 2 { - return types.ErrEncodingError.SetLog(Fmt("Expected 'pubkey/power'. Got %v", pubKeyAndPower)) + return types.ErrEncodingError.SetLog(common.Fmt("Expected 'pubkey/power'. Got %v", pubKeyAndPower)) } pubkeyS, powerS := pubKeyAndPower[0], pubKeyAndPower[1] pubkey, err := hex.DecodeString(pubkeyS) if err != nil { - return types.ErrEncodingError.SetLog(Fmt("Pubkey (%s) is invalid hex", pubkeyS)) + return types.ErrEncodingError.SetLog(common.Fmt("Pubkey (%s) is invalid hex", pubkeyS)) } power, err := strconv.Atoi(powerS) if err != nil { - return types.ErrEncodingError.SetLog(Fmt("Power (%s) is not an int", powerS)) + return types.ErrEncodingError.SetLog(common.Fmt("Power (%s) is not an int", powerS)) } // update @@ -210,14 +210,14 @@ func (app *PersistentDummyApplication) updateValidator(v *types.Validator) types if v.Power == 0 { // remove validator if !app.app.state.Has(key) { - return types.ErrUnauthorized.SetLog(Fmt("Cannot remove non-existent validator %X", key)) + return types.ErrUnauthorized.SetLog(common.Fmt("Cannot remove non-existent validator %X", key)) } app.app.state.Remove(key) } else { // add or update validator value := bytes.NewBuffer(make([]byte, 0)) if err := types.WriteMessage(v, value); err != nil { - return types.ErrInternalError.SetLog(Fmt("Error encoding validator: %v", err)) + return types.ErrInternalError.SetLog(common.Fmt("Error encoding validator: %v", err)) } app.app.state.Set(key, value.Bytes()) } diff --git a/example/example_test.go b/example/example_test.go index fb15f503b..945499943 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -7,15 +7,16 @@ import ( "testing" "time" - "golang.org/x/net/context" "google.golang.org/grpc" + "golang.org/x/net/context" + "github.com/tendermint/abci/client" "github.com/tendermint/abci/example/dummy" nilapp "github.com/tendermint/abci/example/nil" "github.com/tendermint/abci/server" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func TestDummy(t *testing.T) { @@ -40,14 +41,14 @@ func testStream(t *testing.T, app types.Application) { // Start the listener server, err := server.NewSocketServer("unix://test.sock", app) if err != nil { - Exit(Fmt("Error starting socket server: %v", err.Error())) + common.Exit(common.Fmt("Error starting socket server: %v", err.Error())) } defer server.Stop() // Connect to the socket client, err := abcicli.NewSocketClient("unix://test.sock", false) if err != nil { - Exit(Fmt("Error starting socket client: %v", err.Error())) + common.Exit(common.Fmt("Error starting socket client: %v", err.Error())) } client.Start() defer client.Stop() @@ -113,14 +114,14 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) { // Start the listener server, err := server.NewGRPCServer("unix://test.sock", app) if err != nil { - Exit(Fmt("Error starting GRPC server: %v", err.Error())) + common.Exit(common.Fmt("Error starting GRPC server: %v", err.Error())) } defer server.Stop() // Connect to the socket conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc)) if err != nil { - Exit(Fmt("Error dialing GRPC server: %v", err.Error())) + common.Exit(common.Fmt("Error dialing GRPC server: %v", err.Error())) } defer conn.Close() diff --git a/server/grpc_server.go b/server/grpc_server.go index 07704c321..3893b20b9 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -7,13 +7,13 @@ import ( "google.golang.org/grpc" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) // var maxNumberConnections = 2 type GRPCServer struct { - BaseService + common.BaseService proto string addr string @@ -23,7 +23,7 @@ type GRPCServer struct { app types.ABCIApplicationServer } -func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (Service, error) { +func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (common.Service, error) { parts := strings.SplitN(protoAddr, "://", 2) proto, addr := parts[0], parts[1] s := &GRPCServer{ @@ -32,7 +32,7 @@ func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (Service, listener: nil, app: app, } - s.BaseService = *NewBaseService(nil, "ABCIServer", s) + s.BaseService = *common.NewBaseService(nil, "ABCIServer", s) _, err := s.Start() // Just start it return s, err } diff --git a/server/server.go b/server/server.go index 6de8747b7..1d42e7d51 100644 --- a/server/server.go +++ b/server/server.go @@ -4,11 +4,11 @@ import ( "fmt" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) -func NewServer(protoAddr, transport string, app types.Application) (Service, error) { - var s Service +func NewServer(protoAddr, transport string, app types.Application) (common.Service, error) { + var s common.Service var err error switch transport { case "socket": diff --git a/server/socket_server.go b/server/socket_server.go index 1ef47859f..06bf03984 100644 --- a/server/socket_server.go +++ b/server/socket_server.go @@ -9,13 +9,13 @@ import ( "sync" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) // var maxNumberConnections = 2 type SocketServer struct { - BaseService + common.BaseService proto string addr string @@ -29,7 +29,7 @@ type SocketServer struct { app types.Application } -func NewSocketServer(protoAddr string, app types.Application) (Service, error) { +func NewSocketServer(protoAddr string, app types.Application) (common.Service, error) { parts := strings.SplitN(protoAddr, "://", 2) proto, addr := parts[0], parts[1] s := &SocketServer{ @@ -39,7 +39,7 @@ func NewSocketServer(protoAddr string, app types.Application) (Service, error) { app: app, conns: make(map[int]net.Conn), } - s.BaseService = *NewBaseService(nil, "ABCIServer", s) + s.BaseService = *common.NewBaseService(nil, "ABCIServer", s) _, err := s.Start() // Just start it return s, err } @@ -100,7 +100,7 @@ func (s *SocketServer) acceptConnectionsRoutine() { if !s.IsRunning() { return // Ignore error from listener closing. } - Exit("Failed to accept connection: " + err.Error()) + common.Exit("Failed to accept connection: " + err.Error()) } else { log.Notice("Accepted a new connection") } diff --git a/tests/benchmarks/parallel/parallel.go b/tests/benchmarks/parallel/parallel.go index 51d9a6366..9b7176f3e 100644 --- a/tests/benchmarks/parallel/parallel.go +++ b/tests/benchmarks/parallel/parallel.go @@ -3,17 +3,16 @@ package main import ( "bufio" "fmt" - //"encoding/hex" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func main() { - conn, err := Connect("unix://test.sock") + conn, err := common.Connect("unix://test.sock") if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } // Read a bunch of responses @@ -23,7 +22,7 @@ func main() { var res = &types.Response{} err := types.ReadMessage(conn, res) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } counter += 1 if counter%1000 == 0 { @@ -40,11 +39,11 @@ func main() { err := types.WriteMessage(req, bufWriter) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } err = bufWriter.Flush() if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } counter += 1 diff --git a/tests/benchmarks/simple/simple.go b/tests/benchmarks/simple/simple.go index b1b71fb72..5076dc7a1 100644 --- a/tests/benchmarks/simple/simple.go +++ b/tests/benchmarks/simple/simple.go @@ -6,17 +6,16 @@ import ( "fmt" "net" "reflect" - //"encoding/hex" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" ) func main() { - conn, err := Connect("unix://test.sock") + conn, err := common.Connect("unix://test.sock") if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } // Make a bunch of requests @@ -25,7 +24,7 @@ func main() { req := types.ToRequestEcho("foobar") _, err := makeRequest(conn, req) if err != nil { - Exit(err.Error()) + common.Exit(err.Error()) } counter += 1 if counter%1000 == 0 { @@ -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("Expected flush response but got something else: %v", reflect.TypeOf(resFlush))) + return nil, errors.New(common.Fmt("Expected flush response but got something else: %v", reflect.TypeOf(resFlush))) } return res, nil diff --git a/tests/test_app/app.go b/tests/test_app/app.go index b84b9386f..ef9322788 100644 --- a/tests/test_app/app.go +++ b/tests/test_app/app.go @@ -7,7 +7,7 @@ import ( "github.com/tendermint/abci/client" "github.com/tendermint/abci/types" - . "github.com/tendermint/go-common" + common "github.com/tendermint/go-common" "github.com/tendermint/go-process" ) @@ -46,7 +46,7 @@ func SetOption(client abcicli.Client, key, value string) { res := client.SetOptionSync(key, value) _, _, log := res.Code, res.Data, res.Log if res.IsErr() { - panic(Fmt("setting %v=%v: \nlog: %v", key, value, log)) + panic(common.Fmt("setting %v=%v: \nlog: %v", key, value, log)) } } @@ -54,10 +54,10 @@ func Commit(client abcicli.Client, hashExp []byte) { res := client.CommitSync() _, data, log := res.Code, res.Data, res.Log if res.IsErr() { - panic(Fmt("committing %v\nlog: %v", log)) + panic(common.Fmt("committing %v\nlog: %v", log)) } if !bytes.Equal(res.Data, hashExp) { - panic(Fmt("Commit hash was unexpected. Got %X expected %X", + panic(common.Fmt("Commit hash was unexpected. Got %X expected %X", data, hashExp)) } } @@ -66,11 +66,11 @@ func DeliverTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, da res := client.DeliverTxSync(txBytes) code, data, log := res.Code, res.Data, res.Log if code != codeExp { - panic(Fmt("DeliverTx response code was unexpected. Got %v expected %v. Log: %v", + panic(common.Fmt("DeliverTx response code was unexpected. Got %v expected %v. Log: %v", code, codeExp, log)) } if !bytes.Equal(data, dataExp) { - panic(Fmt("DeliverTx response data was unexpected. Got %X expected %X", + panic(common.Fmt("DeliverTx response data was unexpected. Got %X expected %X", data, dataExp)) } } @@ -79,14 +79,14 @@ func CheckTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, data res := client.CheckTxSync(txBytes) code, data, log := res.Code, res.Data, res.Log if res.IsErr() { - panic(Fmt("checking tx %X: %v\nlog: %v", txBytes, log)) + panic(common.Fmt("checking tx %X: %v\nlog: %v", txBytes, log)) } if code != codeExp { - panic(Fmt("CheckTx response code was unexpected. Got %v expected %v. Log: %v", + panic(common.Fmt("CheckTx response code was unexpected. Got %v expected %v. Log: %v", code, codeExp, log)) } if !bytes.Equal(data, dataExp) { - panic(Fmt("CheckTx response data was unexpected. Got %X expected %X", + panic(common.Fmt("CheckTx response data was unexpected. Got %X expected %X", data, dataExp)) } }