mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 20:21:56 +00:00
lint: s/common.Fmt/fmt.Sprintf
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
Reference in New Issue
Block a user