MCPcopy Create free account
hub / github.com/CPChain/chain / sendBatchHTTP

Method sendBatchHTTP

api/rpc/http.go:114–129  ·  view source on GitHub ↗
(ctx context.Context, op *requestOp, msgs []*jsonrpcMessage)

Source from the content-addressed store, hash-verified

112}
113
114func (c *Client) sendBatchHTTP(ctx context.Context, op *requestOp, msgs []*jsonrpcMessage) error {
115 hc := c.writeConn.(*httpConn)
116 respBody, err := hc.doRequest(ctx, msgs)
117 if err != nil {
118 return err
119 }
120 defer respBody.Close()
121 var respmsgs []jsonrpcMessage
122 if err := json.NewDecoder(respBody).Decode(&respmsgs); err != nil {
123 return err
124 }
125 for i := 0; i < len(respmsgs); i++ {
126 op.resp <- &respmsgs[i]
127 }
128 return nil
129}
130
131func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadCloser, error) {
132 body, err := json.Marshal(msg)

Callers 1

BatchCallContextMethod · 0.95

Calls 2

doRequestMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected