You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// BatchCallContext sends all given requests as a single batch and waits for the server
// to return a response for all of them. The wait duration is bounded by the
// context's deadline.
func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
var (
msgs = make([]*jsonrpcMessage, len(b))
byID = make(map[string]int, len(b))
)
for i, elem := range b {
msg, err := c.newMessage(elem.Method, elem.Args...)
if err != nil {
return err
}
msgs[i] = msg
byID[string(msg.ID)] = i
}
respBody, err := c.doRequest(ctx, msgs)
if err != nil {
return err
}
defer respBody.Close()
**//Need to add error handling here**
var respmsgs []jsonrpcMessage
if err := json.NewDecoder(respBody).Decode(&respmsgs); err != nil {
return err
}
for idx, resp := range respmsgs {
elem := &b[idx]
if resp.Error != nil {
elem.Error = resp.Error
continue
}
if len(resp.Result) == 0 {
elem.Error = ErrNoResult
continue
}
elem.Error = json.Unmarshal(resp.Result, elem.Result)
}
return nil
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: