node

package
v0.0.7-alphanet Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: GPL-3.0 Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultWalletDir = "wallet"
)

Variables

View Source
var (
	ErrDataDirUsed = errors.New("dataDir already used by another process")
	ErrNodeStopped = errors.New("node not started")
)
View Source
var DefaultNodeConfig = Config{
	DataPath: DefaultDataDir(),

	Name: p2p.DefaultNodeName,

	LogLevel: "info",

	RPC: RPCConfig{
		HTTPPort:   p2p.DefaultHTTPPort,
		HTTPHost:   "0.0.0.0",
		EnableHTTP: true,
		WSPort:     p2p.DefaultWSPort,
		WSHost:     "0.0.0.0",
		EnableWS:   true,

		HTTPCors:  []string{"*"},
		WSOrigins: []string{"*"},
	},
	Net: NetConfig{
		ListenHost:        p2p.DefaultListenHost,
		ListenPort:        p2p.DefaultListenPort,
		MinPeers:          p2p.DefaultMinPeers,
		MinConnectedPeers: p2p.DefaultMinConnectedPeers,
		MaxPeers:          p2p.DefaultMaxPeers,
		MaxPendingPeers:   p2p.DefaultMaxPendingPeers,
		Seeders:           p2p.DefaultSeeders,
	},
}

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is the default data directory to use for the databases and other persistence requirements.

func NewHTTPHandlerStack

func NewHTTPHandlerStack(srv http.Handler, cors []string, vhosts []string) http.Handler

NewHTTPHandlerStack returns wrapped http-related handlers

func RegisterApisFromWhitelist

func RegisterApisFromWhitelist(apis []rpc.API, modules []string, srv *rpc.Server, exposeAll bool) error

RegisterApisFromWhitelist checks the given modules' availability, generates a whitelist based on the allowed modules, and then registers all of the APIs exposed by the services.

func ReplaceHomeVariable

func ReplaceHomeVariable(path string) string

Types

type Config

type Config struct {
	DataPath    string // default ~/.zenon
	WalletPath  string // default DataPath/wallet
	GenesisFile string // GenesisFile is the absolute path to the genesis file

	Name string

	LogLevel string // "debug", "dbug" | "info" | "warn" | "error", "error" | "crit"

	Producer *ProducerConfig
	RPC      RPCConfig
	Net      NetConfig
}

func (*Config) HTTPEndpoint

func (c *Config) HTTPEndpoint() string

func (*Config) MakePathsAbsolute

func (c *Config) MakePathsAbsolute() error

func (*Config) WSEndpoint

func (c *Config) WSEndpoint() string

type NetConfig

type NetConfig struct {
	ListenHost string
	ListenPort int

	MinPeers          int
	MinConnectedPeers int
	MaxPeers          int
	MaxPendingPeers   int

	Seeders []string
}

type Node

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

Node is chain container that manages p2p、rpc、zenon modules

func NewNode

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

func (*Node) Config

func (node *Node) Config() *Config

func (*Node) Start

func (node *Node) Start() error

func (*Node) Stop

func (node *Node) Stop() error

func (*Node) Wait

func (node *Node) Wait()

func (*Node) WalletManager

func (node *Node) WalletManager() *wallet.Manager

func (*Node) Zenon

func (node *Node) Zenon() zenon.Zenon

type ProducerConfig

type ProducerConfig struct {
	Address     string
	Index       uint32
	KeyFilePath string
	Password    string
}

type RPCConfig

type RPCConfig struct {
	EnableHTTP bool
	EnableWS   bool

	HTTPHost string
	HTTPPort int
	WSHost   string
	WSPort   int

	Endpoints []string

	HTTPVirtualHosts []string
	HTTPCors         []string
	WSOrigins        []string
}

Jump to

Keyboard shortcuts

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