mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
rpc: fix staticcheck warnings
This commit is contained in:
parent
444da8204f
commit
3e090bda5d
5 changed files with 9 additions and 17 deletions
|
|
@ -189,7 +189,7 @@ func (h *handler) cancelAllRequests(err error, inflightReq *requestOp) {
|
|||
}
|
||||
for id, sub := range h.clientSubs {
|
||||
delete(h.clientSubs, id)
|
||||
sub.quitWithError(err, false)
|
||||
sub.quitWithError(false, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,14 +153,6 @@ type ConnRemoteAddr interface {
|
|||
RemoteAddr() string
|
||||
}
|
||||
|
||||
// connWithRemoteAddr overrides the remote address of a connection.
|
||||
type connWithRemoteAddr struct {
|
||||
Conn
|
||||
addr string
|
||||
}
|
||||
|
||||
func (c connWithRemoteAddr) RemoteAddr() string { return c.addr }
|
||||
|
||||
// jsonCodec reads and writes JSON-RPC messages to the underlying connection. It also has
|
||||
// support for parsing arguments and serializing (result) objects.
|
||||
type jsonCodec struct {
|
||||
|
|
|
|||
|
|
@ -241,11 +241,11 @@ func (sub *ClientSubscription) Err() <-chan error {
|
|||
// Unsubscribe unsubscribes the notification and closes the error channel.
|
||||
// It can safely be called more than once.
|
||||
func (sub *ClientSubscription) Unsubscribe() {
|
||||
sub.quitWithError(nil, true)
|
||||
sub.quitWithError(true, nil)
|
||||
sub.errOnce.Do(func() { close(sub.err) })
|
||||
}
|
||||
|
||||
func (sub *ClientSubscription) quitWithError(err error, unsubscribeServer bool) {
|
||||
func (sub *ClientSubscription) quitWithError(unsubscribeServer bool, err error) {
|
||||
sub.quitOnce.Do(func() {
|
||||
// The dispatch loop won't be able to execute the unsubscribe call
|
||||
// if it is blocked on deliver. Close sub.quit first because it
|
||||
|
|
@ -276,7 +276,7 @@ func (sub *ClientSubscription) start() {
|
|||
sub.quitWithError(sub.forward())
|
||||
}
|
||||
|
||||
func (sub *ClientSubscription) forward() (err error, unsubscribeServer bool) {
|
||||
func (sub *ClientSubscription) forward() (unsubscribeServer bool, err error) {
|
||||
cases := []reflect.SelectCase{
|
||||
{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(sub.quit)},
|
||||
{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(sub.in)},
|
||||
|
|
@ -298,14 +298,14 @@ func (sub *ClientSubscription) forward() (err error, unsubscribeServer bool) {
|
|||
|
||||
switch chosen {
|
||||
case 0: // <-sub.quit
|
||||
return nil, false
|
||||
return false, nil
|
||||
case 1: // <-sub.in
|
||||
val, err := sub.unmarshal(recv.Interface().(json.RawMessage))
|
||||
if err != nil {
|
||||
return err, true
|
||||
return true, err
|
||||
}
|
||||
if buffer.Len() == maxClientSubscriptionBuffer {
|
||||
return ErrSubscriptionQueueOverflow, true
|
||||
return true, ErrSubscriptionQueueOverflow
|
||||
}
|
||||
buffer.PushBack(val)
|
||||
case 2: // sub.channel<-
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ func (s *testService) Rets() (string, error) {
|
|||
return "", nil
|
||||
}
|
||||
|
||||
//lint:ignore ST1008 returns error first on purpose.
|
||||
func (s *testService) InvalidRets1() (error, string) {
|
||||
return nil, ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,9 +97,8 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
|||
return err
|
||||
}
|
||||
if blckNum > math.MaxInt64 {
|
||||
return fmt.Errorf("Blocknumber too high")
|
||||
return fmt.Errorf("block number larger than int64")
|
||||
}
|
||||
|
||||
*bn = BlockNumber(blckNum)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue