p2p, log, rpc: use errors.New to replace fmt.Errorf with no parameters (#29074)
This commit is contained in:
parent
32d4d6e616
commit
26724fc2aa
@ -2,6 +2,7 @@ package log
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
@ -77,7 +78,7 @@ func benchmarkLogger(b *testing.B, l Logger) {
|
||||
tt = time.Now()
|
||||
bigint = big.NewInt(100)
|
||||
nilbig *big.Int
|
||||
err = fmt.Errorf("Oh nooes it's crap")
|
||||
err = errors.New("Oh nooes it's crap")
|
||||
)
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
@ -106,7 +107,7 @@ func TestLoggerOutput(t *testing.T) {
|
||||
tt = time.Time{}
|
||||
bigint = big.NewInt(100)
|
||||
nilbig *big.Int
|
||||
err = fmt.Errorf("Oh nooes it's crap")
|
||||
err = errors.New("Oh nooes it's crap")
|
||||
smallUint = uint256.NewInt(500_000)
|
||||
bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff}
|
||||
)
|
||||
|
@ -914,13 +914,13 @@ func (srv *Server) checkInboundConn(remoteIP net.IP) error {
|
||||
}
|
||||
// Reject connections that do not match NetRestrict.
|
||||
if srv.NetRestrict != nil && !srv.NetRestrict.Contains(remoteIP) {
|
||||
return fmt.Errorf("not in netrestrict list")
|
||||
return errors.New("not in netrestrict list")
|
||||
}
|
||||
// Reject Internet peers that try too often.
|
||||
now := srv.clock.Now()
|
||||
srv.inboundHistory.expire(now, nil)
|
||||
if !netutil.IsLAN(remoteIP) && srv.inboundHistory.contains(remoteIP.String()) {
|
||||
return fmt.Errorf("too many attempts")
|
||||
return errors.New("too many attempts")
|
||||
}
|
||||
srv.inboundHistory.add(remoteIP.String(), now.Add(inboundThrottleTime))
|
||||
return nil
|
||||
|
@ -19,6 +19,7 @@ package p2p
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@ -157,7 +158,7 @@ func readProtocolHandshake(rw MsgReader) (*protoHandshake, error) {
|
||||
return nil, err
|
||||
}
|
||||
if msg.Size > baseProtocolMaxMsgSize {
|
||||
return nil, fmt.Errorf("message too big")
|
||||
return nil, errors.New("message too big")
|
||||
}
|
||||
if msg.Code == discMsg {
|
||||
// Disconnect before protocol handshake is valid according to the
|
||||
|
@ -19,6 +19,7 @@ package rpc
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
@ -104,7 +105,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
||||
return err
|
||||
}
|
||||
if blckNum > math.MaxInt64 {
|
||||
return fmt.Errorf("block number larger than int64")
|
||||
return errors.New("block number larger than int64")
|
||||
}
|
||||
*bn = BlockNumber(blckNum)
|
||||
return nil
|
||||
@ -154,7 +155,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
||||
err := json.Unmarshal(data, &e)
|
||||
if err == nil {
|
||||
if e.BlockNumber != nil && e.BlockHash != nil {
|
||||
return fmt.Errorf("cannot specify both BlockHash and BlockNumber, choose one or the other")
|
||||
return errors.New("cannot specify both BlockHash and BlockNumber, choose one or the other")
|
||||
}
|
||||
bnh.BlockNumber = e.BlockNumber
|
||||
bnh.BlockHash = e.BlockHash
|
||||
@ -202,7 +203,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
||||
return err
|
||||
}
|
||||
if blckNum > math.MaxInt64 {
|
||||
return fmt.Errorf("blocknumber too high")
|
||||
return errors.New("blocknumber too high")
|
||||
}
|
||||
bn := BlockNumber(blckNum)
|
||||
bnh.BlockNumber = &bn
|
||||
|
Loading…
Reference in New Issue
Block a user