Documentation
¶
Index ¶
- Variables
- func DefaultDataDir() string
- func MakeAccountManager(conf *NodeConfig) (*accounts.Manager, error)
- type DuplicateServiceError
- type FTransService
- type FTransServiceConstructor
- type FTransServiceContext
- func (ctx *FTransServiceContext) OpenDatabase(name string, cache int, handles int) (ethdb.Database, error)
- func (ctx *FTransServiceContext) ResolvePath(path string) string
- func (ctx *FTransServiceContext) Service(service interface{}) error
- func (s *FTransServiceContext) SetService(kind reflect.Type, srv FTransService)
- type Node
- type NodeConfig
- type StopError
Constants ¶
This section is empty.
Variables ¶
var ( ErrDatadirUsed = errors.New("datadir already used by another process") ErrNodeStopped = errors.New("node not started") ErrNodeRunning = errors.New("node already running") ErrServiceUnknown = errors.New("unknown service") )
var DefaultConfig = NodeConfig{ DataDir: DefaultDataDir(), }
DefaultConfig contains reasonable default settings.
Functions ¶
func DefaultDataDir ¶
func DefaultDataDir() string
DefaultDataDir is the default data directory to use for the databases and other persistence requirements.
func MakeAccountManager ¶
func MakeAccountManager(conf *NodeConfig) (*accounts.Manager, error)
Types ¶
type DuplicateServiceError ¶
DuplicateServiceError is returned during Node startup if a registered service constructor returns a service of the same type that was already started.
func (*DuplicateServiceError) Error ¶
func (e *DuplicateServiceError) Error() string
Error generates a textual representation of the duplicate service error.
type FTransService ¶
type FTransService 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. StartClient(*p2p.Client) error // Stop terminates all goroutines belonging to the service, blocking until they // are all terminated. Stop() error }
type FTransServiceConstructor ¶
type FTransServiceConstructor func(ctx *FTransServiceContext) (FTransService, error)
ServiceConstructor is the function signature of the constructors needed to be registered for service instantiation.
type FTransServiceContext ¶
type FTransServiceContext struct { Config *NodeConfig Services map[reflect.Type]FTransService // Index of the already constructed services EventMux *event.TypeMux // Event multiplexer used for decoupled notifications AccountManager *accounts.Manager // Account manager created by the node. }
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 (*FTransServiceContext) OpenDatabase ¶
func (ctx *FTransServiceContext) OpenDatabase(name string, cache int, handles int) (ethdb.Database, error)
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 (*FTransServiceContext) ResolvePath ¶
func (ctx *FTransServiceContext) 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 (*FTransServiceContext) Service ¶
func (ctx *FTransServiceContext) Service(service interface{}) error
Service retrieves a currently running service registered of a specific type.
func (*FTransServiceContext) SetService ¶
func (s *FTransServiceContext) SetService(kind reflect.Type, srv FTransService)
type Node ¶
type Node struct { FTransAPI *ftransfer.PrivateFTransAPI Peer *p2p.Peer // contains filtered or unexported fields }
Node is a container on which services can be registered.
func New ¶
func New(conf *NodeConfig) (*Node, error)
New creates a new P2P node, ready for protocol registration.
func (*Node) GetConfig ¶
func (n *Node) GetConfig() *NodeConfig
GetConfig retrieves the node config.
func (*Node) Register ¶
func (n *Node) Register(constructor FTransServiceConstructor) 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) SetConfig ¶
func (n *Node) SetConfig(cfg *NodeConfig)
SetConfig retrieves the node config.
type NodeConfig ¶
type NodeConfig struct { // Name sets the instance name of the node. It must not contain the / character and is // used in the devp2p node identifier. The instance name of geth is "geth". If no // value is specified, the basename of the current executable is used. Name string `toml:"-"` // BasePassphrase used for the base passphrase of the FTP BaseAddress string BasePassphrase string // Version should be set to the version number of the program. It is used // in the devp2p node identifier. Version string `toml:"-"` // DataDir is the file system folder the node should use for any data storage // requirements. The configured data directory will not be directly shared with // registered services, instead those can use utility methods to create/access // databases or flat files. This enables ephemeral nodes which can fully reside // in memory. DataDir string // Configuration of peer-to-peer networking. P2P p2p.ClientCfg // 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. These values can be further extended by all registered services.
func (*NodeConfig) AccountConfig ¶
func (c *NodeConfig) AccountConfig() (int, int, string)
AccountConfig determines the settings for scrypt and keydirectory
func (*NodeConfig) NodeDB ¶
func (c *NodeConfig) NodeDB() string
NodeDB returns the path to the discovery node database.
func (*NodeConfig) NodeKey ¶
func (c *NodeConfig) NodeKey() *ecdsa.PrivateKey
NodeKey retrieves the currently configured private key of the node, checking first any manually set key, falling back to the one found in the configured data folder. If no key can be found, a new one is generated.
func (*NodeConfig) NodeName ¶
func (c *NodeConfig) NodeName() string
NodeName returns the devp2p node identifier.
func (*NodeConfig) StaticNodes ¶
func (c *NodeConfig) StaticNodes() []*discover.Node
StaticNodes returns a list of node enode URLs configured as static nodes.