Merge tag 'v1.10.12' into HEAD
This commit is contained in:
+8
-11
@@ -17,7 +17,6 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -360,7 +359,10 @@ func (c *Client) BatchCall(b []BatchElem) error {
|
||||
//
|
||||
// Note that batch calls may not be executed atomically on the server side.
|
||||
func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
|
||||
msgs := make([]*jsonrpcMessage, len(b))
|
||||
var (
|
||||
msgs = make([]*jsonrpcMessage, len(b))
|
||||
byID = make(map[string]int, len(b))
|
||||
)
|
||||
op := &requestOp{
|
||||
ids: make([]json.RawMessage, len(b)),
|
||||
resp: make(chan *jsonrpcMessage, len(b)),
|
||||
@@ -372,6 +374,7 @@ func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
|
||||
}
|
||||
msgs[i] = msg
|
||||
op.ids[i] = msg.ID
|
||||
byID[string(msg.ID)] = i
|
||||
}
|
||||
|
||||
var err error
|
||||
@@ -391,13 +394,7 @@ func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
|
||||
// Find the element corresponding to this response.
|
||||
// The element is guaranteed to be present because dispatch
|
||||
// only sends valid IDs to our channel.
|
||||
var elem *BatchElem
|
||||
for i := range msgs {
|
||||
if bytes.Equal(msgs[i].ID, resp.ID) {
|
||||
elem = &b[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
elem := &b[byID[string(resp.ID)]]
|
||||
if resp.Error != nil {
|
||||
elem.Error = resp.Error
|
||||
continue
|
||||
@@ -426,12 +423,12 @@ func (c *Client) Notify(ctx context.Context, method string, args ...interface{})
|
||||
return c.send(ctx, op, msg)
|
||||
}
|
||||
|
||||
// EthSubscribe registers a subscripion under the "eth" namespace.
|
||||
// EthSubscribe registers a subscription under the "eth" namespace.
|
||||
func (c *Client) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*ClientSubscription, error) {
|
||||
return c.Subscribe(ctx, "eth", channel, args...)
|
||||
}
|
||||
|
||||
// ShhSubscribe registers a subscripion under the "shh" namespace.
|
||||
// ShhSubscribe registers a subscription under the "shh" namespace.
|
||||
// Deprecated: use Subscribe(ctx, "shh", ...).
|
||||
func (c *Client) ShhSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*ClientSubscription, error) {
|
||||
return c.Subscribe(ctx, "shh", channel, args...)
|
||||
|
||||
@@ -186,6 +186,16 @@ func (bnh *BlockNumberOrHash) Number() (BlockNumber, bool) {
|
||||
return BlockNumber(0), false
|
||||
}
|
||||
|
||||
func (bnh *BlockNumberOrHash) String() string {
|
||||
if bnh.BlockNumber != nil {
|
||||
return strconv.Itoa(int(*bnh.BlockNumber))
|
||||
}
|
||||
if bnh.BlockHash != nil {
|
||||
return bnh.BlockHash.String()
|
||||
}
|
||||
return "nil"
|
||||
}
|
||||
|
||||
func (bnh *BlockNumberOrHash) Hash() (common.Hash, bool) {
|
||||
if bnh.BlockHash != nil {
|
||||
return *bnh.BlockHash, true
|
||||
|
||||
Reference in New Issue
Block a user