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

Function newClient

api/rpc/client.go:223–247  ·  view source on GitHub ↗
(initctx context.Context, connectFunc func(context.Context) (net.Conn, error))

Source from the content-addressed store, hash-verified

221}
222
223func newClient(initctx context.Context, connectFunc func(context.Context) (net.Conn, error)) (*Client, error) {
224 conn, err := connectFunc(initctx)
225 if err != nil {
226 return nil, err
227 }
228 _, isHTTP := conn.(*httpConn)
229 c := &Client{
230 writeConn: conn,
231 isHTTP: isHTTP,
232 connectFunc: connectFunc,
233 close: make(chan struct{}),
234 didQuit: make(chan struct{}),
235 reconnected: make(chan net.Conn),
236 readErr: make(chan error),
237 readResp: make(chan []*jsonrpcMessage),
238 requestOp: make(chan *requestOp),
239 sendDone: make(chan error, 1),
240 respWait: make(map[string]*requestOp),
241 subs: make(map[string]*ClientSubscription),
242 }
243 if !isHTTP {
244 go c.dispatch(conn)
245 }
246 return c, nil
247}
248
249func (c *Client) nextID() json.RawMessage {
250 id := atomic.AddUint32(&c.idCounter, 1)

Callers 5

DialInProcFunction · 0.85
DialHTTPWithClientFunction · 0.85
DialWebsocketFunction · 0.85
DialIPCFunction · 0.85
DialStdIOFunction · 0.85

Calls 1

dispatchMethod · 0.95

Tested by

no test coverage detected