mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
lint: s/common.Fmt/fmt.Sprintf
This commit is contained in:
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user