lint: s/common.Fmt/fmt.Sprintf

This commit is contained in:
Tzu-Jung Lee
2017-01-16 22:59:46 -08:00
parent fcaa545e1e
commit 1150bbfe36
11 changed files with 43 additions and 39 deletions

View File

@ -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))
}