node

package
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2019 License: LGPL-3.0 Imports: 15 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigIsNull       = errors.New("config info is null")
	ErrLogIsNull          = errors.New("SeeleLog is null")
	ErrNodeRunning        = errors.New("node is already running")
	ErrNodeStopped        = errors.New("node is not started")
	ErrServiceStartFailed = errors.New("failed to start node service")
	ErrServiceStopFailed  = errors.New("failed to stop node service")
)

error infos

Functions

This section is empty.

Types

type BasicConfig

type BasicConfig struct {
	// The name of the node
	Name string `json:"name"`

	// The version of the node
	Version string `json:"version"`

	// The file system path of the node, used to store data
	DataDir string `json:"dataDir"`

	// The file system path of the temporary dataset, used for spow
	DataSetDir string `json:"dataSetDir"`

	// RPCAddr is the address on which to start RPC server.
	RPCAddr string `json:"address"`

	// coinbase used by the miner
	Coinbase string `json:"coinbase"`

	// privatekey for coinbase, used in bft consensus
	PrivateKey string `json:"privateKey"`

	// MinerAlgorithm miner algorithm
	MinerAlgorithm string `json:"algorithm"`
}

BasicConfig config for Node

type Config

type Config struct {
	//Config is the Configuration of log
	LogConfig comm.LogConfig

	// basic config for Node
	BasicConfig BasicConfig

	// The configuration of p2p network
	P2PConfig p2p.Config

	// HttpServer config for http server
	HTTPServer HTTPServer

	// The SeeleConfig is the configuration to create the seele service.
	SeeleConfig SeeleConfig

	// The configuration of websocket rpc service
	WSServerConfig WSServerConfig

	// The configuration of ipc rpc service
	IpcConfig IpcConfig

	// metrics config info
	MetricsConfig *metrics.Config
}

Config is the Configuration of node

func (*Config) Clone

func (conf *Config) Clone() *Config

type HTTPServer

type HTTPServer struct {
	// The HTTPAddr is the address of HTTP rpc service
	HTTPAddr string `json:"address"`

	// HTTPCors is the Cross-Origin Resource Sharing header to send to requesting
	// clients. Please be aware that CORS is a browser enforced security, it's fully
	// useless for custom HTTP clients.
	HTTPCors []string `json:"crossorigins"`

	// HTTPHostFilter is the whitelist of hostnames which are allowed on incoming requests.
	HTTPWhiteHost []string `json:"whiteHost"`
}

HTTPServer config for http server

type IpcConfig

type IpcConfig struct {
	PipeName string `json:"name"`
}

IpcConfig config for ipc rpc service

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is a container for registering services.

func New

func New(conf *Config) (*Node, error)

New creates a new P2P node.

func (*Node) GetShardNumber

func (n *Node) GetShardNumber() uint

func (*Node) Register

func (n *Node) Register(service Service) error

Register appends a new service into the node's stack.

func (*Node) Start

func (n *Node) Start() error

Start starts the p2p node.

func (*Node) Stop

func (n *Node) Stop() error

Stop terminates the running node and services registered.

type SeeleConfig

type SeeleConfig struct {
	TxConf core.TransactionPoolConfig

	Coinbase common.Address

	CoinbasePrivateKey *ecdsa.PrivateKey

	GenesisConfig core.GenesisInfo
}

Config is the seele's configuration to create seele service

type Service

type Service interface {
	// Protocols retrieves the P2P protocols the service wishes to start.
	Protocols() []p2p.Protocol

	APIs() (apis []rpc.API)

	Start(server *p2p.Server) error

	Stop() error
}

Service represents a service which is registered to the node after the node starts.

type StopError

type StopError struct {
	Services map[reflect.Type]error // Services is a container mapping the type of services which fail to stop to error
}

StopError represents an error which is returned when a node fails to stop any registered service

func (*StopError) Error

func (se *StopError) Error() string

Error returns a string representation of the stop error.

type WSServerConfig

type WSServerConfig struct {
	// The Address is the address of Websocket rpc service
	Address string `json:"address"`

	CrossOrigins []string `json:"crossorigins"`
}

WSServerConfig config for websocket server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL