Register injects a new service into the node's stack. The service created by the passed constructor must be unique in its type with regard to sibling ones.
(constructor ServiceConstructor)
| 114 | // Register injects a new service into the node's stack. The service created by |
| 115 | // the passed constructor must be unique in its type with regard to sibling ones. |
| 116 | func (n *Node) Register(constructor ServiceConstructor) error { |
| 117 | n.lock.Lock() |
| 118 | defer n.lock.Unlock() |
| 119 | |
| 120 | if n.server != nil { |
| 121 | return ErrNodeRunning |
| 122 | } |
| 123 | n.serviceFuncs = append(n.serviceFuncs, constructor) |
| 124 | return nil |
| 125 | } |
| 126 | |
| 127 | // Start creates a p2p node and begins the service |
| 128 | func (n *Node) Start() error { |