les, signer, light: replace noarg fmt.Errorf with errors.New (#27336)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
21c87e0f1b
commit
dd25a4f5ab
@ -19,7 +19,7 @@ package les
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"errors"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"sync"
|
||||
@ -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
|
||||
@ -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
|
||||
}
|
||||
@ -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)
|
||||
|
@ -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
|
||||
|
@ -18,7 +18,7 @@
|
||||
package les
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -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
|
||||
|
@ -18,7 +18,7 @@ package les
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package light
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package rules
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user