config

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestnetFlag = cli.BoolFlag{
		Name:  "testnet, t",
		Usage: "test network: pre-configured test network",
	}

	NodeConfigFlag = cli.StringFlag{
		Name:  "config, c",
		Usage: "load configuration from `FILE`",
	}

	NodeNameFlag = cli.StringFlag{
		Name:  "nodename",
		Usage: "gyee node name",
		Value: "MyNode",
	}

	NodeDirFlag = cli.StringFlag{
		Name:  "nodedir, d",
		Usage: "gyee node root directory",
	}

	//AppConfig Flags
	AppFlags = []cli.Flag{
		AppLogLevelFlag,
		AppLogFileFlag,
		AppEnableCrashReportFlag,
		AppCrashReportUrlFlag,
	}

	AppLogLevelFlag = cli.StringFlag{
		Name:  "loglevel",
		Usage: "log level",
	}

	AppLogFileFlag = cli.StringFlag{
		Name:  "logfile",
		Usage: "log file",
	}

	AppEnableCrashReportFlag = cli.BoolFlag{
		Name:  "enable_crash_report",
		Usage: "enable crash report",
	}

	AppCrashReportUrlFlag = cli.StringSliceFlag{
		Name:  "crash_report_url",
		Usage: "crash report url",
	}

	//NetworkConfig Flags
	NetworkFlags = []cli.Flag{
		NetworkBootNodeFlag,
		NetworkListenFlag,
		NetworkIPFlag,
	}

	NetworkBootNodeFlag = cli.StringSliceFlag{
		Name:  "bootnode",
		Usage: "boot node",
	}

	NetworkIPFlag = cli.StringFlag{
		Name:  "localip",
		Usage: "local IP",
	}

	NetworkListenFlag = cli.StringSliceFlag{
		Name:  "p2p_listen",
		Usage: "p2p netowrk listen port",
	}

	//RpcConfig Flags
	RpcFlags = []cli.Flag{
		RpcIpcPathFlag,
		RpcListenFlag,
		RpcHttpListenFlag,
	}

	RpcIpcPathFlag = cli.StringFlag{
		Name:  "ipcpath",
		Usage: "ipc path",
	}

	RpcListenFlag = cli.StringSliceFlag{
		Name:  "rpc_listen",
		Usage: "rpc listen",
	}

	RpcHttpListenFlag = cli.StringSliceFlag{
		Name:  "http_listen",
		Usage: "http listen",
	}

	//ChainConfig Flags
	ChainFlags = []cli.Flag{
		ChainIDFlag,
		ChainDataDirFlag,
		ChainKeyDirFlag,
		ChainGenesisFlag,
		ChainMineFlag,
		ChainCoinbaseFlag,
		ChainPwdFileFlag,
	}

	ChainIDFlag = cli.IntFlag{
		Name:  "chainid",
		Usage: "chain id",
	}

	ChainDataDirFlag = cli.StringFlag{
		Name:  "datadir",
		Usage: "chain data dir",
	}

	ChainKeyDirFlag = cli.StringFlag{
		Name:  "keydir",
		Usage: "key dir",
	}

	ChainGenesisFlag = cli.StringFlag{
		Name:  "genesis",
		Usage: "genesis file path",
	}

	ChainMineFlag = cli.BoolFlag{
		Name:  "mine",
		Usage: "mine",
	}

	ChainCoinbaseFlag = cli.StringFlag{
		Name:  "coinbase",
		Usage: "coinbase address for node",
	}

	ChainPwdFileFlag = cli.StringFlag{
		Name:  "pwdfile",
		Usage: "pwdfile for coinbase keystore",
	}

	//MetricsConfig Flags
	MetricsFlags = []cli.Flag{
		MetricsEnableFlag,
		MetricsEnableReportFlag,
		MetricsReportUrlFlag,
	}

	MetricsEnableFlag = cli.BoolFlag{
		Name:  "metrics_enable",
		Usage: "metrics enable",
	}

	MetricsEnableReportFlag = cli.BoolFlag{
		Name:  "metrics_report",
		Usage: "metrics enable report",
	}

	MetricsReportUrlFlag = cli.StringSliceFlag{
		Name:  "metrics_report_url",
		Usage: "metrics report url",
	}

	//MiscConfig Flags
	MiscFlags = []cli.Flag{}
)

Functions

func FlagName

func FlagName(name string) string

func MergeFlags

func MergeFlags(action func(ctx *cli.Context) error) func(*cli.Context) error

func SaveConfigToFile

func SaveConfigToFile(file string, config *Config) error

Types

type AppConfig

type AppConfig struct {
	LogLevel          string   `toml:"log_level"`
	LogFile           string   `toml:"log_file"`
	EnableCrashReport bool     `toml:"enable_crash_report"`
	CrashReportUrl    []string `toml:"crash_report_url"`
}

type ChainConfig

type ChainConfig struct {
	ChainID  uint32 `toml:"chain_id"`
	DataDir  string `toml:"data_dir"`
	KeyDir   string `toml:"key_dir"`
	Genesis  string `toml:"genesis"`
	Mine     bool   `toml:"mine"`
	Coinbase string `toml:"coinbase"`
	PwdFile  string `toml:"pwdfile"`
	Key      []byte // raw private key used in unit test
}

Genesis, ChainID, Keydir, Coinbase, gas...

type Config

type Config struct {
	Name    string         `toml:"name"`
	NodeDir string         `toml:"node_dir"`
	App     *AppConfig     `toml:"app"`
	P2p     *P2pConfig     `toml:"network"`
	Rpc     *RpcConfig     `toml:"rpc"`
	Chain   *ChainConfig   `toml:"chain"`
	Metrics *MetricsConfig `toml:"metrics"`
	Misc    *MiscConfig    `toml:"misc"`
}

func GetConfig

func GetConfig(ctx *cli.Context) *Config

func GetConfigFromFile

func GetConfigFromFile(file string, config *Config) *Config

func GetDefaultConfig

func GetDefaultConfig() *Config

func (*Config) IPCEndpoint

func (c *Config) IPCEndpoint() string

type MetricsConfig

type MetricsConfig struct {
	EnableMetrics       bool     `toml:"enable_metrics"`
	EnableMetricsReport bool     `toml:"enable_metrics_report"`
	MetricsReportUrl    []string `toml:"metrics_report_url"`
}

cpu, mem, disk profile,

type MiscConfig

type MiscConfig struct {
}

type P2pConfig

type P2pConfig struct {
	BootNode []string `toml:"bootnode"`
	Listen   []string `toml:"listen"`

	AppType           int      `toml:"app_type"`
	Name              string   `toml:"name"`
	Validator         bool     `toml:"validator"`
	BootstrapNode     bool     `toml:"bootstrap_node"`
	BootstrapNodes    []string `toml:"bootstrap_nodes"`
	DhtBootstrapNodes []string `toml:"dht_bootstrap_nodes"`
	LocalNodeIp       string   `toml:"local_node_ip"`
	LocalUdpPort      uint16   `toml:"local_udp_port"`
	LocalTcpPort      uint16   `toml:"local_tcp_port"`
	LocalDhtIp        string   `toml:"local_dht_ip"`
	LocalDhtPort      uint16   `toml:"local_dht_port"`
	NodeDataDir       string   `toml:"node_data_path"`
	NodeDatabase      string   `toml:"node_database"`
	SubNetMaskBits    int      `toml:"subnet_mask_bits"`
	EvKeepTime        int      `toml:"ev_keep_time"`
	DedupTime         int      `toml:"dedup_time"`
	BootstrapTime     int      `toml:"bootstrap_time"`
	NatType           string   `toml:"nat_type"`
	GatewayIp         string   `toml:"gateway_ip"`
}

P2P Config, bootnode, MaxConn, MaxIncoming, MaxOutgoing, Listen Port,..

type RpcConfig

type RpcConfig struct {
	IpcPath    string   `toml:"ipc_path"`
	RpcListen  []string `toml:"rpc_listen"`
	HttpListen []string `toml:"http_listen"`
}

Listen addr, modules, access right

Jump to

Keyboard shortcuts

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