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

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