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

Method Service

node/node.go:505–520  ·  view source on GitHub ↗

Service retrieves and sets a currently running service registered of a specific type.

(service interface{})

Source from the content-addressed store, hash-verified

503
504// Service retrieves and sets a currently running service registered of a specific type.
505func (n *Node) Service(service interface{}) error {
506 n.lock.RLock()
507 defer n.lock.RUnlock()
508
509 // Short circuit if the node's not running
510 if n.server == nil {
511 return ErrNodeStopped
512 }
513 // Otherwise try to find the service to return
514 element := reflect.ValueOf(service).Elem()
515 if running, ok := n.services[element.Type()]; ok {
516 element.Set(reflect.ValueOf(running))
517 return nil
518 }
519 return ErrServiceUnknown
520}
521
522// creates the directory and adds the lock
523func (n *Node) openDataDir() error {

Callers 4

setupMiningFunction · 0.45
handleInterruptFunction · 0.45
TestContextServicesFunction · 0.45
TestServiceRetrievalFunction · 0.45

Calls 2

TypeMethod · 0.80
SetMethod · 0.45

Tested by 2

TestContextServicesFunction · 0.36
TestServiceRetrievalFunction · 0.36