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

Method startWS

node/node.go:362–378  ·  view source on GitHub ↗

startWS initializes and starts the websocket RPC endpoint.

(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool)

Source from the content-addressed store, hash-verified

360
361// startWS initializes and starts the websocket RPC endpoint.
362func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins []string, exposeAll bool) error {
363 // Short circuit if the WS endpoint isn't being exposed
364 if endpoint == "" {
365 return nil
366 }
367 listener, handler, err := rpc.StartWSEndpoint(endpoint, apis, modules, wsOrigins, exposeAll)
368 if err != nil {
369 return err
370 }
371 n.log.Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr()))
372 // All listeners booted successfully
373 n.wsEndpoint = endpoint
374 n.wsListener = listener
375 n.wsHandler = handler
376
377 return nil
378}
379
380// stopWS terminates the websocket RPC endpoint.
381func (n *Node) stopWS() {

Callers 2

startRPCMethod · 0.95
StartWSMethod · 0.80

Calls 1

InfoMethod · 0.65

Tested by

no test coverage detected