mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 02:31:46 +00:00
lint: s/common.Fmt/fmt.Sprintf
This commit is contained in:
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/abci/server"
|
||||
"github.com/tendermint/abci/types"
|
||||
@ -58,7 +59,7 @@ func (app *ChainAwareApplication) Commit() types.Result {
|
||||
}
|
||||
|
||||
func (app *ChainAwareApplication) Query(query []byte) types.Result {
|
||||
return types.NewResultOK([]byte(common.Fmt("%d,%d", app.beginCount, app.endCount)), "")
|
||||
return types.NewResultOK([]byte(fmt.Sprintf("%d,%d", app.beginCount, app.endCount)), "")
|
||||
}
|
||||
|
||||
func (app *ChainAwareApplication) BeginBlock(hash []byte, header *types.Header) {
|
||||
|
@ -2,9 +2,9 @@ package counter
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/abci/types"
|
||||
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: common.Fmt("{\"hashes\":%v,\"txs\":%v}", app.hashCount, app.txCount)}
|
||||
return types.ResponseInfo{Data: fmt.Sprintf("{\"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(common.Fmt("Max tx size is 8 bytes, got %d", len(tx)))
|
||||
return types.ErrEncodingError.SetLog(fmt.Sprintf("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(common.Fmt("Invalid nonce. Expected %v, got %v", app.txCount, txValue))
|
||||
return types.ErrBadNonce.SetLog(fmt.Sprintf("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(common.Fmt("Max tx size is 8 bytes, got %d", len(tx)))
|
||||
return types.ErrEncodingError.SetLog(fmt.Sprintf("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(common.Fmt("Invalid nonce. Expected >= %v, got %v", app.txCount, txValue))
|
||||
return types.ErrBadNonce.SetLog(fmt.Sprintf("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, common.Fmt("%v", app.hashCount))
|
||||
return types.NewResultOK(nil, fmt.Sprintf("%v", app.hashCount))
|
||||
case "tx":
|
||||
return types.NewResultOK(nil, common.Fmt("%v", app.txCount))
|
||||
return types.NewResultOK(nil, fmt.Sprintf("%v", app.txCount))
|
||||
}
|
||||
|
||||
return types.ErrUnknownRequest.SetLog(common.Fmt("Invalid nonce. Expected hash or tx, got %v", queryStr))
|
||||
return types.ErrUnknownRequest.SetLog(fmt.Sprintf("Invalid nonce. Expected hash or tx, got %v", queryStr))
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package dummy
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/abci/types"
|
||||
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: common.Fmt("{\"size\":%v}", app.state.Size())}
|
||||
return types.ResponseInfo{Data: fmt.Sprintf("{\"size\":%v}", app.state.Size())}
|
||||
}
|
||||
|
||||
func (app *DummyApplication) SetOption(key string, value string) (log string) {
|
||||
|
@ -2,6 +2,7 @@ package dummy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"testing"
|
||||
@ -107,7 +108,7 @@ func TestValSetChanges(t *testing.T) {
|
||||
nInit := 5
|
||||
vals := make([]*types.Validator, total)
|
||||
for i := 0; i < total; i++ {
|
||||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(common.Fmt("test%d", i))).PubKey().Bytes()
|
||||
pubkey := crypto.GenPrivKeyEd25519FromSecret([]byte(fmt.Sprintf("test%d", i))).PubKey().Bytes()
|
||||
power := common.RandInt()
|
||||
vals[i] = &types.Validator{pubkey, uint64(power)}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package dummy
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -135,7 +136,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
|
||||
common.Exit(common.Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
common.Exit(fmt.Sprintf("Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
}
|
||||
// TODO: ensure that buf is completely read.
|
||||
}
|
||||
@ -173,7 +174,7 @@ func (app *PersistentDummyApplication) Validators() (validators []*types.Validat
|
||||
}
|
||||
|
||||
func MakeValSetChangeTx(pubkey []byte, power uint64) []byte {
|
||||
return []byte(common.Fmt("val:%X/%d", pubkey, power))
|
||||
return []byte(fmt.Sprintf("val:%X/%d", pubkey, power))
|
||||
}
|
||||
|
||||
func isValidatorTx(tx []byte) bool {
|
||||
@ -188,16 +189,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(common.Fmt("Expected 'pubkey/power'. Got %v", pubKeyAndPower))
|
||||
return types.ErrEncodingError.SetLog(fmt.Sprintf("Expected 'pubkey/power'. Got %v", pubKeyAndPower))
|
||||
}
|
||||
pubkeyS, powerS := pubKeyAndPower[0], pubKeyAndPower[1]
|
||||
pubkey, err := hex.DecodeString(pubkeyS)
|
||||
if err != nil {
|
||||
return types.ErrEncodingError.SetLog(common.Fmt("Pubkey (%s) is invalid hex", pubkeyS))
|
||||
return types.ErrEncodingError.SetLog(fmt.Sprintf("Pubkey (%s) is invalid hex", pubkeyS))
|
||||
}
|
||||
power, err := strconv.Atoi(powerS)
|
||||
if err != nil {
|
||||
return types.ErrEncodingError.SetLog(common.Fmt("Power (%s) is not an int", powerS))
|
||||
return types.ErrEncodingError.SetLog(fmt.Sprintf("Power (%s) is not an int", powerS))
|
||||
}
|
||||
|
||||
// update
|
||||
@ -210,14 +211,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(common.Fmt("Cannot remove non-existent validator %X", key))
|
||||
return types.ErrUnauthorized.SetLog(fmt.Sprintf("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(common.Fmt("Error encoding validator: %v", err))
|
||||
return types.ErrInternalError.SetLog(fmt.Sprintf("Error encoding validator: %v", err))
|
||||
}
|
||||
app.app.state.Set(key, value.Bytes())
|
||||
}
|
||||
|
@ -41,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 {
|
||||
common.Exit(common.Fmt("Error starting socket server: %v", err.Error()))
|
||||
common.Exit(fmt.Sprintf("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 {
|
||||
common.Exit(common.Fmt("Error starting socket client: %v", err.Error()))
|
||||
common.Exit(fmt.Sprintf("Error starting socket client: %v", err.Error()))
|
||||
}
|
||||
client.Start()
|
||||
defer client.Stop()
|
||||
@ -114,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 {
|
||||
common.Exit(common.Fmt("Error starting GRPC server: %v", err.Error()))
|
||||
common.Exit(fmt.Sprintf("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 {
|
||||
common.Exit(common.Fmt("Error dialing GRPC server: %v", err.Error()))
|
||||
common.Exit(fmt.Sprintf("Error dialing GRPC server: %v", err.Error()))
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
|
Reference in New Issue
Block a user