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

Method send

api/rpc/client.go:459–475  ·  view source on GitHub ↗

send registers op with the dispatch loop, then sends msg on the connection. if sending fails, op is deregistered.

(ctx context.Context, op *requestOp, msg interface{})

Source from the content-addressed store, hash-verified

457// send registers op with the dispatch loop, then sends msg on the connection.
458// if sending fails, op is deregistered.
459func (c *Client) send(ctx context.Context, op *requestOp, msg interface{}) error {
460 select {
461 case c.requestOp <- op:
462 log.Debug("", "msg", func() string {
463 return fmt.Sprint("sending ", msg)
464 }())
465 err := c.write(ctx, msg)
466 c.sendDone <- err
467 return err
468 case <-ctx.Done():
469 // This can happen if the client is overloaded or unable to keep up with
470 // subscription notifications.
471 return ctx.Err()
472 case <-c.didQuit:
473 return ErrClientQuit
474 }
475}
476
477func (c *Client) write(ctx context.Context, msg interface{}) error {
478 deadline, ok := ctx.Deadline()

Callers 3

CallContextMethod · 0.95
BatchCallContextMethod · 0.95
SubscribeMethod · 0.95

Calls 3

writeMethod · 0.95
DebugMethod · 0.80
ErrMethod · 0.65

Tested by

no test coverage detected