Version: v0.0.0-...-cd31d1c Latest Latest

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

Go to latest
Published: Apr 2, 2021 License: LGPL-3.0 Imports: 15 Imported by: 0




This section is empty.


View Source
var (
	ErrConfigIsNull       = errors.New("config info is null")
	ErrLogIsNull          = errors.New("ScdoLog 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


This section is empty.


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"`

	// 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 ScdoConfig is the configuration to create the scdo service.
	ScdoConfig ScdoConfig

	// 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 ScdoConfig

type ScdoConfig struct {
	TxConf core.TransactionPoolConfig

	Coinbase common.Address

	CoinbasePrivateKey *ecdsa.PrivateKey

	CoinbaseList []common.Address

	GenesisConfig core.GenesisInfo

Config is the scdo's configuration to create scdo 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
t or T : Toggle theme light dark auto
y or Y : Canonical URL