mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-04 02:52:07 +00:00
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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user