You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
package node
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/p2p"
|
|
"github.com/harmony-one/harmony/rpc"
|
|
)
|
|
|
|
// Service is an individual protocol that can be registered into a node.
|
|
//
|
|
// Notes:
|
|
//
|
|
// • Service life-cycle management is delegated to the node. The service is allowed to
|
|
// initialize itself upon creation, but no goroutines should be spun up outside of the
|
|
// Start method.
|
|
//
|
|
// • Restart logic is not required as the node will create a fresh instance
|
|
// every time a service is started.
|
|
type Service interface {
|
|
// Protocols retrieves the P2P protocols the service wishes to start.
|
|
Protocols() []p2p.Protocol
|
|
|
|
// APIs retrieves the list of RPC descriptors the service provides
|
|
APIs() []rpc.API
|
|
|
|
// Start is called after all services have been constructed and the networking
|
|
// layer was also initialized to spawn any goroutines required by the service.
|
|
Start(server *p2p.Server) error
|
|
|
|
// Stop terminates all goroutines belonging to the service, blocking until they
|
|
// are all terminated.
|
|
Stop() error
|
|
}
|
|
|