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

Method startRPC

node/node.go:237–265  ·  view source on GitHub ↗

startRPC is a helper method to start all the various RPC endpoint during node startup. It's not meant to be called at any time afterwards as it makes certain assumptions about the state of the node.

(services map[reflect.Type]Service)

Source from the content-addressed store, hash-verified

235// startup. It's not meant to be called at any time afterwards as it makes certain
236// assumptions about the state of the node.
237func (n *Node) startRPC(services map[reflect.Type]Service) error {
238 // Gather all the possible APIs to surface
239 apis := n.apis()
240 for _, service := range services {
241 apis = append(apis, service.APIs()...)
242 }
243 // Start the various API endpoints, terminating all in case of errors
244 if err := n.startInProc(apis); err != nil {
245 return err
246 }
247 if err := n.startIPC(apis); err != nil {
248 n.stopInProc()
249 return err
250 }
251 if err := n.startHTTP(n.httpEndpoint, apis, n.config.HTTPModules, n.config.HTTPCors, n.config.HTTPVirtualHosts); err != nil {
252 n.stopIPC()
253 n.stopInProc()
254 return err
255 }
256 if err := n.startWS(n.wsEndpoint, apis, n.config.WSModules, n.config.WSOrigins, n.config.WSExposeAll); err != nil {
257 n.stopHTTP()
258 n.stopIPC()
259 n.stopInProc()
260 return err
261 }
262 // All API endpoints started successfully
263 n.rpcAPIs = apis
264 return nil
265}
266
267func (n *Node) stopRPC() {
268 n.stopWS()

Callers 1

StartMethod · 0.95

Calls 9

apisMethod · 0.95
startInProcMethod · 0.95
startIPCMethod · 0.95
stopInProcMethod · 0.95
startHTTPMethod · 0.95
stopIPCMethod · 0.95
startWSMethod · 0.95
stopHTTPMethod · 0.95
APIsMethod · 0.65

Tested by

no test coverage detected