Skip to content

Commit

Permalink
les, signer, light: replace noarg fmt.Errorf with errors.New (#27336)
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <[email protected]>
  • Loading branch information
jsvisa authored May 25, 2023
1 parent 21c87e0 commit dd25a4f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions les/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package les
import (
crand "crypto/rand"
"encoding/binary"
"fmt"
"errors"
"math/big"
"math/rand"
"sync"
Expand Down Expand Up @@ -59,7 +59,7 @@ func (b *benchmarkBlockHeaders) init(h *serverHandler, count int) error {
b.offset = 0
b.randMax = h.blockchain.CurrentHeader().Number.Int64() + 1 - d
if b.randMax < 0 {
return fmt.Errorf("chain is too short")
return errors.New("chain is too short")
}
if b.reverse {
b.offset = d
Expand Down Expand Up @@ -137,7 +137,7 @@ func (b *benchmarkHelperTrie) init(h *serverHandler, count int) error {
b.headNum = b.sectionCount*params.CHTFrequency - 1
}
if b.sectionCount == 0 {
return fmt.Errorf("no processed sections available")
return errors.New("no processed sections available")
}
return nil
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (h *serverHandler) measure(setup *benchmarkSetup, count int) error {
case <-h.closeCh:
clientPipe.Close()
serverPipe.Close()
return fmt.Errorf("Benchmark cancelled")
return errors.New("Benchmark cancelled")
}

setup.totalTime += time.Duration(mclock.Now() - start)
Expand Down
2 changes: 1 addition & 1 deletion les/catalyst/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config engine.Transit
TerminalBlockNumber: config.TerminalBlockNumber,
}, nil
}
return nil, fmt.Errorf("invalid terminal block hash")
return nil, errors.New("invalid terminal block hash")
}

return &engine.TransitionConfigurationV1{TerminalTotalDifficulty: (*hexutil.Big)(ttd)}, nil
Expand Down
6 changes: 3 additions & 3 deletions les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package les

import (
"fmt"
"errors"
"strings"
"time"

Expand Down Expand Up @@ -268,12 +268,12 @@ type LightDummyAPI struct{}

// Etherbase is the address that mining rewards will be send to
func (s *LightDummyAPI) Etherbase() (common.Address, error) {
return common.Address{}, fmt.Errorf("mining is not supported in light mode")
return common.Address{}, errors.New("mining is not supported in light mode")
}

// Coinbase is the address that mining rewards will be send to (alias for Etherbase)
func (s *LightDummyAPI) Coinbase() (common.Address, error) {
return common.Address{}, fmt.Errorf("mining is not supported in light mode")
return common.Address{}, errors.New("mining is not supported in light mode")
}

// Hashrate returns the POW hashrate
Expand Down
4 changes: 2 additions & 2 deletions les/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package les

import (
"context"
"fmt"
"errors"
"sync"
"time"

Expand Down Expand Up @@ -110,7 +110,7 @@ func (rm *retrieveManager) retrieve(ctx context.Context, reqID uint64, req *dist
case <-ctx.Done():
sentReq.stop(ctx.Err())
case <-shutdown:
sentReq.stop(fmt.Errorf("client is shutting down"))
sentReq.stop(errors.New("client is shutting down"))
}
return sentReq.getError()
}
Expand Down
5 changes: 3 additions & 2 deletions light/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package light
import (
"bytes"
"context"
"errors"
"fmt"
"math/big"
"testing"
Expand Down Expand Up @@ -78,9 +79,9 @@ func diffTries(t1, t2 state.Trie) error {
case i2.Err != nil:
return fmt.Errorf("light trie iterator error: %v", i2.Err)
case i1.Next():
return fmt.Errorf("full trie iterator has more k/v pairs")
return errors.New("full trie iterator has more k/v pairs")
case i2.Next():
return fmt.Errorf("light trie iterator has more k/v pairs")
return errors.New("light trie iterator has more k/v pairs")
}
return nil
}
4 changes: 2 additions & 2 deletions signer/core/signed_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ func (api *SignerAPI) EcRecover(ctx context.Context, data hexutil.Bytes, sig hex
//
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover
if len(sig) != 65 {
return common.Address{}, fmt.Errorf("signature must be 65 bytes long")
return common.Address{}, errors.New("signature must be 65 bytes long")
}
if sig[64] != 27 && sig[64] != 28 {
return common.Address{}, fmt.Errorf("invalid Ethereum signature (V is not 27 or 28)")
return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)")
}
sig[64] -= 27 // Transform yellow paper V from 27/28 to 0/1
hash := accounts.TextHash(data)
Expand Down
2 changes: 1 addition & 1 deletion signer/core/uiapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *UIServerAPI) Export(ctx context.Context, addr common.Address) (json.Raw
return nil, err
}
if wallet.URL().Scheme != keystore.KeyStoreScheme {
return nil, fmt.Errorf("account is not a keystore-account")
return nil, errors.New("account is not a keystore-account")
}
return os.ReadFile(wallet.URL().Path)
}
Expand Down
3 changes: 2 additions & 1 deletion signer/rules/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package rules

import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -146,7 +147,7 @@ func (r *rulesetUI) checkApproval(jsfunc string, jsarg []byte, err error) (bool,
log.Info("Op rejected")
return false, nil
}
return false, fmt.Errorf("unknown response")
return false, errors.New("unknown response")
}

func (r *rulesetUI) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {
Expand Down

0 comments on commit dd25a4f

Please sign in to comment.