Browse Source

Errorf -> fmt.Errorf

pull/55/head
Jae Kwon 9 years ago
parent
commit
df1d46d04d
7 changed files with 20 additions and 25 deletions
  1. +2
    -2
      cmd/barak/main.go
  2. +1
    -1
      cmd/debora/commands.go
  3. +0
    -5
      common/errors.go
  4. +5
    -5
      consensus/pol.go
  5. +7
    -8
      rpc/http_params.go
  6. +2
    -1
      state/execution.go
  7. +3
    -3
      state/validator_set.go

+ 2
- 2
cmd/barak/main.go View File

@ -151,7 +151,7 @@ func RunProcess(wait bool, label string, execPath string, args []string, input s
existing := barak.processes[label]
if existing != nil {
barak.mtx.Unlock()
return nil, Errorf("Process already exists: %v", label)
return nil, fmt.Errorf("Process already exists: %v", label)
}
// Otherwise, create one.
@ -173,7 +173,7 @@ func StopProcess(label string, kill bool) (*ResponseStopProcess, error) {
barak.mtx.Unlock()
if proc == nil {
return nil, Errorf("Process does not exist: %v", label)
return nil, fmt.Errorf("Process does not exist: %v", label)
}
err := pcm.Stop(proc, kill)


+ 1
- 1
cmd/debora/commands.go View File

@ -27,7 +27,7 @@ func GetNonce(remote string) uint64 {
response := btypes.ResponseStatus{}
_, err = rpc.Call(remote, "status", Arr(), &response)
if err != nil {
panic(Fmt("Error fetching nonce from remote %v: %v", remote, err))
Exit(Fmt("Error fetching nonce from remote %v: %v", remote, err))
}
return response.Nonce
}


+ 0
- 5
common/errors.go View File

@ -1,14 +1,9 @@
package common
import (
"errors"
"fmt"
)
func Errorf(s string, args ...interface{}) error {
return errors.New(fmt.Sprintf(s, args...))
}
type StackError struct {
Err interface{}
Stack []byte


+ 5
- 5
consensus/pol.go View File

@ -33,7 +33,7 @@ type POL struct {
func (pol *POL) Verify(valSet *sm.ValidatorSet) error {
if uint(len(pol.Votes)) != valSet.Size() {
return Errorf("Invalid POL votes count: Expected %v, got %v",
return fmt.Errorf("Invalid POL votes count: Expected %v, got %v",
valSet.Size(), len(pol.Votes))
}
@ -61,16 +61,16 @@ func (pol *POL) Verify(valSet *sm.ValidatorSet) error {
BlockParts: pol.BlockParts,
})
} else if vote.Round > pol.Round {
return Errorf("Invalid commit round %v for POL %v", vote.Round, pol)
return fmt.Errorf("Invalid commit round %v for POL %v", vote.Round, pol)
}
// Validate
if _, seen := seenValidators[string(val.Address)]; seen {
return Errorf("Duplicate validator for vote %v for POL %v", vote, pol)
return fmt.Errorf("Duplicate validator for vote %v for POL %v", vote, pol)
}
if !val.PubKey.VerifyBytes(voteDoc, vote.Signature) {
return Errorf("Invalid signature for vote %v for POL %v", vote, pol)
return fmt.Errorf("Invalid signature for vote %v for POL %v", vote, pol)
}
// Tally
@ -81,7 +81,7 @@ func (pol *POL) Verify(valSet *sm.ValidatorSet) error {
if talliedVotingPower > valSet.TotalVotingPower()*2/3 {
return nil
} else {
return Errorf("Invalid POL, insufficient voting power %v, needed %v",
return fmt.Errorf("Invalid POL, insufficient voting power %v, needed %v",
talliedVotingPower, (valSet.TotalVotingPower()*2/3 + 1))
}


+ 7
- 8
rpc/http_params.go View File

@ -2,11 +2,10 @@ package rpc
import (
"encoding/hex"
"fmt"
"net/http"
"regexp"
"strconv"
. "github.com/tendermint/tendermint/common"
)
var (
@ -44,7 +43,7 @@ func GetParamInt64(r *http.Request, param string) (int64, error) {
s := GetParam(r, param)
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0, Errorf(param, err.Error())
return 0, fmt.Errorf(param, err.Error())
}
return i, nil
}
@ -53,7 +52,7 @@ func GetParamInt32(r *http.Request, param string) (int32, error) {
s := GetParam(r, param)
i, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return 0, Errorf(param, err.Error())
return 0, fmt.Errorf(param, err.Error())
}
return int32(i), nil
}
@ -62,7 +61,7 @@ func GetParamUint64(r *http.Request, param string) (uint64, error) {
s := GetParam(r, param)
i, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, Errorf(param, err.Error())
return 0, fmt.Errorf(param, err.Error())
}
return i, nil
}
@ -71,7 +70,7 @@ func GetParamUint(r *http.Request, param string) (uint, error) {
s := GetParam(r, param)
i, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return 0, Errorf(param, err.Error())
return 0, fmt.Errorf(param, err.Error())
}
return uint(i), nil
}
@ -79,7 +78,7 @@ func GetParamUint(r *http.Request, param string) (uint, error) {
func GetParamRegexp(r *http.Request, param string, re *regexp.Regexp) (string, error) {
s := GetParam(r, param)
if !re.MatchString(s) {
return "", Errorf(param, "Did not match regular expression %v", re.String())
return "", fmt.Errorf(param, "Did not match regular expression %v", re.String())
}
return s, nil
}
@ -88,7 +87,7 @@ func GetParamFloat64(r *http.Request, param string) (float64, error) {
s := GetParam(r, param)
f, err := strconv.ParseFloat(s, 64)
if err != nil {
return 0, Errorf(param, err.Error())
return 0, fmt.Errorf(param, err.Error())
}
return f, nil
}

+ 2
- 1
state/execution.go View File

@ -3,6 +3,7 @@ package state
import (
"bytes"
"errors"
"fmt"
"github.com/tendermint/tendermint/account"
. "github.com/tendermint/tendermint/common"
@ -20,7 +21,7 @@ func ExecBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeade
// State.Hash should match block.StateHash
stateHash := s.Hash()
if !bytes.Equal(stateHash, block.StateHash) {
return Errorf("Invalid state hash. Expected %X, got %X",
return fmt.Errorf("Invalid state hash. Expected %X, got %X",
stateHash, block.StateHash)
}
return nil


+ 3
- 3
state/validator_set.go View File

@ -225,11 +225,11 @@ func (valSet *ValidatorSet) VerifyValidation(hash []byte, parts types.PartSetHea
// Validate
if _, seen := seenValidators[string(val.Address)]; seen {
return Errorf("Duplicate validator for commit %v for Validation %v", commit, v)
return fmt.Errorf("Duplicate validator for commit %v for Validation %v", commit, v)
}
if !val.PubKey.VerifyBytes(commitSignBytes, commit.Signature) {
return Errorf("Invalid signature for commit %v for Validation %v", commit, v)
return fmt.Errorf("Invalid signature for commit %v for Validation %v", commit, v)
}
// Tally
@ -240,7 +240,7 @@ func (valSet *ValidatorSet) VerifyValidation(hash []byte, parts types.PartSetHea
if talliedVotingPower > valSet.TotalVotingPower()*2/3 {
return nil
} else {
return Errorf("insufficient voting power %v, needed %v",
return fmt.Errorf("insufficient voting power %v, needed %v",
talliedVotingPower, (valSet.TotalVotingPower()*2/3 + 1))
}
}


Loading…
Cancel
Save