Documentation ¶
Overview ¶
Copyright 2020 YOUCHAIN FOUNDATION LTD. Copyright 2016 The go-ethereum Authors This file is part of the go-ethereum library.
The go-ethereum library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The go-ethereum library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func DefaultIPCEndpoint(clientIdentifier string) string
- type Config
- func (c *Config) BlacklistDB() string
- func (c *Config) IPCEndpoint() string
- func (c *Config) NodeDB() string
- func (c *Config) NodeKey() *ecdsa.PrivateKey
- func (c *Config) NodeName() string
- func (c *Config) ResolvePath(path string) string
- func (c *Config) StaticNodes() []*enode.Node
- func (c *Config) TrustedNodes() []*enode.Node
- func (c *Config) Type() params.NodeType
- type DuplicateServiceError
- type InfluxDBConfig
- type MetricsConfig
- type Node
- func (n *Node) APIs() []rpc.API
- func (n *Node) Attach() (*rpc.Client, error)
- func (n *Node) GetP2pServer() *p2p.Server
- func (n *Node) Register(constructor ServiceConstructor) error
- func (n *Node) Server() *p2p.Server
- func (n *Node) Start() error
- func (n *Node) StartHTTP(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error)
- func (n *Node) StartRPC(apis []rpc.API) error
- func (n *Node) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error)
- func (n *Node) Stop() error
- func (n *Node) StopRPC() (bool, error)
- func (n *Node) StopWS() (bool, error)
- func (n *Node) Wait()
- type PrivateAdminApi
- func (api *PrivateAdminApi) AddPeer(url string) (bool, error)
- func (api *PrivateAdminApi) Blacklist() RPCBlacklistItem
- func (api *PrivateAdminApi) ClearBlacklistDB()
- func (api *PrivateAdminApi) RemovePeer(url string) (bool, error)
- func (api *PrivateAdminApi) RemovePeerFromBlacklist(ip string, rudpPort int) bool
- func (api *PrivateAdminApi) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error)
- func (api *PrivateAdminApi) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error)
- func (api *PrivateAdminApi) StopRPC() (bool, error)
- func (api *PrivateAdminApi) StopWS() (bool, error)
- type PublicAdminApi
- type PublicNetApi
- type PublicNodeApi
- type RPCBlacklistItem
- type Service
- type ServiceConstructor
- type ServiceContext
- type StopError
Constants ¶
const ( ConsTypeYPoS = iota ConsTypeSolo )
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 = Config{ Name: "YOUChain", DataDir: "data", NetworkId: 1, RPC: rpc.NewDefaultConfig(), P2P: p2p.NewDefaultConfig(), // contains filtered or unexported fields } )
Functions ¶
func DefaultIPCEndpoint ¶
DefaultIPCEndpoint returns the IPC path used by default.
Types ¶
type Config ¶
type Config struct { Name string `yaml:"name" json:"name"` DataDir string `yaml:"datadir" json:"data_dir"` NodeType string `yaml:"nodetype" json:"node_type"` NetworkId uint64 `yaml:"networkid" json:"network_id"` //rpc config RPC rpc.Config `yaml:"rpc" json:"rpc"` //p2p config P2P p2p.Config `yaml:"p2p" json:"p2p"` P2PBootNode string `yaml:"p2pbootnode" json:"p2p_bootnode"` P2pPort int `yaml:"p2pport" json:"p2p_port"` P2pDiscover int `yaml:"p2pdiscover" json:"p2p_discover"` //miner config MiningEnabled bool `yaml:"mine" json:"mine"` //validator config ValAddr string `yaml:"valaddr" json:"val_addr"` Password string `yaml:"-" json:"-"` Keep bool `yaml:"keep" json:"keep"` //whether to keep the validator key in plaintext //developer consensus config Genesis string `yaml:"genesis" json:"genesis"` ConsType int `yaml:"constype" json:"cons_type"` //consensus type: 0 - YPOS, 1 - Solo UConKey string `yaml:"uconkey" json:"ucon_key"` BlsSignKey string `yaml:"blssignkey" json:"bls_sign_key"` SoloBlockTime time.Duration `yaml:"soloblocktime" json:"solo_block_time"` //Metrics config Metrics MetricsConfig `yaml:"metrics" json:"metrics"` //DevOp config LogLevel int `yaml:"loglevel" json:"log_level"` LogVmodule string `yaml:"logvmodule" json:"log_vmodule"` LogPath string `yaml:"logpath" json:"log_path"` BootNodeId int `yaml:"bootnodeid" json:"boot_nodeid"` BootUconFile string `yaml:"bootuconfile" json:"bootuconfile"` BootNodeSvcName string `yaml:"bootnodesvcname" json:"boot_node_svc_name"` // contains filtered or unexported fields }
func NewDefaultConfig ¶
func NewDefaultConfig() Config
func (*Config) BlacklistDB ¶
func (*Config) IPCEndpoint ¶
IPCEndpoint resolves an IPC 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) ResolvePath ¶
func (*Config) StaticNodes ¶
func (*Config) TrustedNodes ¶
TrustedNodes returns a list of node enode URLs configured as trusted nodes.
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 InfluxDBConfig ¶
type MetricsConfig ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) GetP2pServer ¶
func (*Node) Register ¶
func (n *Node) Register(constructor ServiceConstructor) error
func (*Node) Server ¶
Server retrieves the currently running P2P network layer. This method is meant only to inspect fields of the currently running server, life cycle management should be left to this Node entity.
func (*Node) StartRPC ¶
startRPC is a helper method to start all the various RPC endpoint during node startup. It's not meant to be called at any time afterwards as it makes certain assumptions about the state of the node.
type PrivateAdminApi ¶
type PrivateAdminApi struct {
// contains filtered or unexported fields
}
func NewPrivateAdminApi ¶
func NewPrivateAdminApi(node *Node) *PrivateAdminApi
func (*PrivateAdminApi) AddPeer ¶
func (api *PrivateAdminApi) AddPeer(url string) (bool, error)
AddPeer requests connecting to a remote node, and also maintaining the new connection at all times, even reconnecting if it is lost.
func (*PrivateAdminApi) Blacklist ¶
func (api *PrivateAdminApi) Blacklist() RPCBlacklistItem
func (*PrivateAdminApi) ClearBlacklistDB ¶
func (api *PrivateAdminApi) ClearBlacklistDB()
func (*PrivateAdminApi) RemovePeer ¶
func (api *PrivateAdminApi) RemovePeer(url string) (bool, error)
RemovePeer disconnects from a remote node if the connection exists
func (*PrivateAdminApi) RemovePeerFromBlacklist ¶
func (api *PrivateAdminApi) RemovePeerFromBlacklist(ip string, rudpPort int) bool
func (*PrivateAdminApi) StartRPC ¶
func (api *PrivateAdminApi) StartRPC(host *string, port *int, cors *string, apis *string, vhosts *string) (bool, error)
StopRPC terminates an already running HTTP RPC API endpoint.
func (*PrivateAdminApi) StartWS ¶
func (api *PrivateAdminApi) StartWS(host *string, port *int, allowedOrigins *string, apis *string) (bool, error)
StartWS starts the websocket RPC API server.
func (*PrivateAdminApi) StopRPC ¶
func (api *PrivateAdminApi) StopRPC() (bool, error)
StopRPC terminates an already running HTTP RPC API endpoint.
func (*PrivateAdminApi) StopWS ¶
func (api *PrivateAdminApi) StopWS() (bool, error)
StopRPC terminates an already running HTTP RPC API endpoint.
type PublicAdminApi ¶
type PublicAdminApi struct {
// contains filtered or unexported fields
}
func NewPublicAdminApi ¶
func NewPublicAdminApi(node *Node) *PublicAdminApi
type PublicNetApi ¶
type PublicNetApi struct {
// contains filtered or unexported fields
}
public api for net
func NewPublicNetApi ¶
func NewPublicNetApi(node *Node) *PublicNetApi
func (*PublicNetApi) Listening ¶
func (p *PublicNetApi) Listening() bool
Listening returns an indication if the node is listening for network connections.
func (*PublicNetApi) PeerCount ¶
func (p *PublicNetApi) PeerCount() hexutil.Uint
PeerCount returns the number of connected peers
func (*PublicNetApi) Version ¶
func (p *PublicNetApi) Version() string
type PublicNodeApi ¶
type PublicNodeApi struct {
// contains filtered or unexported fields
}
public api for youchain
func NewPublicNodeApi ¶
func NewPublicNodeApi(node *Node) *PublicNodeApi
func (*PublicNodeApi) ClientVersion ¶
func (n *PublicNodeApi) ClientVersion() string
ClientVersion returns the node name
type RPCBlacklistItem ¶
type RPCBlacklistItem struct { Count int ItemsInfo []p2p.BlacklistItem }
type Service ¶
type Service interface { // Protocols retrieves the P2P protocols the service wishes to start. Protocols() []p2p.Protocol // 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 }
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 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 { EventMux *event.TypeMux // Event multiplexer used for decoupled notifications // 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) OpenDatabase ¶
func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int) (youdb.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 (*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.