Documentation ¶
Index ¶
- Variables
- type Config
- func (c *Config) BootNodes() []*enode.Node
- func (c *Config) HTTPEndpoint() string
- func (c *Config) IPCEndpoint() string
- func (c *Config) NodeDB() string
- func (c *Config) NodeKey() *ecdsa.PrivateKey
- func (c *Config) StaticNodes() []*enode.Node
- func (c *Config) TrustedNodes() []*enode.Node
- func (c *Config) WSEndpoint() string
- type Node
- type Service
- type ServiceConstructor
- type ServiceContext
- type StopError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServiceUnknown unknown service ErrServiceUnknown = errors.New("unknown service") // ErrDatadirUsed datadir already used by another process,datadir can only be accessed by a process. ErrDatadirUsed = errors.New("datadir already used by another process") // ErrNodeStopped node not started ErrNodeStopped = errors.New("node not started") // ErrNodeRunning node already running ErrNodeRunning = errors.New("node already running") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string DataDir string `mapstructure:"datadir"` IPCPath string `mapstructure:"ipcpath"` HTTPHost string `mapstructure:"httphost"` HTTPPort int `mapstructure:"httpport"` HTTPModules []string `mapstructure:"httpmodules"` HTTPCors []string `mapstructure:"httpcors"` HTTPVirtualHosts []string `mapstructure:"httpvirtualhosts"` WSHost string `mapstructure:"wshost"` WSPort int `mapstructure:"wsport"` WSModules []string `mapstructure:"wsmodules"` WSOrigins []string `mapstructure:"wsorigins"` WSExposeAll bool `mapstructure:"wsexposall"` // p2p P2PBootNodes string `mapstructure:"bootnodes"` P2PStaticNodes string `mapstructure:"staticnodes"` P2PTrustNodes string `mapstructure:"trustnodes"` P2PNodeDatabase string `mapstructure:"nodedb"` P2PConfig *p2p.Config `mapstructure:"p2p"` // Logger is a custom logger to use with the p2p.Server. Logger log.Logger `toml:",omitempty"` }
Config represents a small collection of configuration values to fine tune the P2P network layer of a protocol stack.
func (*Config) HTTPEndpoint ¶
HTTPEndpoint resolves an HTTP endpoint based on the configured host interface and port parameters.
func (*Config) IPCEndpoint ¶
IPCEndpoint resolves an RPC endpoint based on a configured value, taking into account the set data folders as well as the designated platform we're currently running on.
func (*Config) NodeKey ¶
func (c *Config) NodeKey() *ecdsa.PrivateKey
func (*Config) StaticNodes ¶
StaticNodes returns a list of node enode URLs configured as static nodes.
func (*Config) TrustedNodes ¶
TrustedNodes returns a list of node enode URLs configured as trusted nodes.
func (*Config) WSEndpoint ¶
WSEndpoint resolves a websocket endpoint based on the configured host interface and port parameters.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a container on which services can be registered.
func (*Node) GetNodeConfig ¶
func (n *Node) GetNodeConfig() *ServiceContext
func (*Node) Register ¶
func (n *Node) Register(constructor ServiceConstructor) error
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.
func (*Node) Restart ¶
Restart terminates a running node and boots up a new one in its place. If the node isn't running, an error is returned.
type Service ¶
type Service interface { // todo 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. // todo Start(server *p2p.Server) error Start() error // Stop terminates all goroutines belonging to the service, blocking until they // are all terminated. Stop() error }
Service is an individual protocol that can be registered into a node.
type ServiceConstructor ¶
type ServiceConstructor func(ctx *ServiceContext) (Service, error)
ServiceConstructor is the function signature of the constructors needed to be registered for service instantiation.
type ServiceContext ¶
type ServiceContext struct { P2P *adaptor.ProtoAdaptor // contains filtered or unexported fields }
ServiceContext is a collection of service independent options inherited from the protocol stack, that is passed to all constructors to be optionally used; as well as utility methods to operate on the service environment.
func (*ServiceContext) AppendBootNodes ¶
func (ctx *ServiceContext) AppendBootNodes(nodes []string)
AppendBootNodes the enode URLs of the P2P bootstrap nodes running on the network.
func (*ServiceContext) OpenDatabase ¶
OpenDatabase opens an existing database with the given name (or creates one if no previous can be found) from within the node's data directory. If the node is an ephemeral one, a memory database is returned.
func (*ServiceContext) ResolvePath ¶
func (ctx *ServiceContext) ResolvePath(path string) string
ResolvePath resolves a user path into the data directory if that was relative and if the user actually uses persistent storage. It will return an empty string for emphemeral storage and the user's own input for absolute paths.
func (*ServiceContext) Service ¶
func (ctx *ServiceContext) Service(service interface{}) error
Service retrieves a currently running service registered of a specific type.