config

package
v0.0.0-...-d9e9996 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeModeNormal NODE_MODE_NORMAL node mode for normal
	NodeModeNormal = "Normal"
	// NodeModeFastSync NODE_MODE_FAST_SYNC node mode for fast
	NodeModeFastSync        = "FastSync"
	DefaultNetPort          = 47101             // p2p port
	DefaultNetKeyPath       = "./data/netkeys/" // node private key path
	DefaultNetIsNat         = true              // use NAT
	DefaultNetIsSecure      = true              // use encrypted secure transport
	DefaultNetIsHidden      = false
	DefaultMaxStreamLimits  = 1024
	DefaultMaxMessageSize   = 128
	DefaultTimeout          = 3
	DefaultIsAuthentication = false
	DefautltAuthTimeout     = 30
	// limitation size for same ip
	DefaultStreamIPLimitSize = 10
)

default settings

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleConfig

type ConsoleConfig struct {
	Keys       string
	Name       string
	Host       string
	MaxMsgSize int
}

ConsoleConfig is the command config user input

func (*ConsoleConfig) ApplyFlags

func (cmd *ConsoleConfig) ApplyFlags(flags *pflag.FlagSet)

ApplyFlags apply flag to console command

type DBCacheConfig

type DBCacheConfig struct {
	MemCacheSize int `yaml:"memcache,omitempty"`
	FdCacheSize  int `yaml:"fdcache,omitempty"`
}

DBCacheConfig db cache config

type FeeConfig

type FeeConfig struct {
	NeedFee bool `yaml:"needFee,omitempty"`
	// UnitFee tx 每kb大小的单价
	UnitFee int64 `yaml:"unitFee,omitempty"`
}

FeeConfig is the config of Fee

type KernelConfig

type KernelConfig struct {
	MinNewChainAmount string          `yaml:"minNewChainAmount,omitempty"`
	NewChainWhiteList map[string]bool `yaml:"newChainWhiteList,omitempty"`
}

KernelConfig kernel config

type LogConfig

type LogConfig struct {
	Module         string `yaml:"module,omitempty"`
	Filepath       string `yaml:"filepath,omitempty"`
	Filename       string `yaml:"filename,omitempty"`
	Fmt            string `yaml:"fmt,omitempty"`
	Console        bool   `yaml:"console,omitempty"`
	Level          string `yaml:"level,omitempty"`
	Async          bool   `yaml:"async,omitempty"`
	RotateInterval int    `yaml:"rotateinterval,omitempty"`
	RotateBackups  int    `yaml:"rotatebackups,omitempty"`
}

LogConfig is the log config of node

type MinerConfig

type MinerConfig struct {
	Keypath string `yaml:"keypath,omitempty"`
}

MinerConfig is the config of miner

type NativeConfig

type NativeConfig struct {
	// Timeout (in seconds) to stop native code process
	StopTimeout int
	Deploy      NativeDeployConfig
	Docker      NativeDockerConfig
}

NativeConfig contains the two above config

type NativeDeployConfig

type NativeDeployConfig struct {
	WhiteList struct {
		Enable    bool
		Addresses []string
	}
}

NativeDeployConfig native contract deploy config

type NativeDockerConfig

type NativeDockerConfig struct {
	Enable    bool
	ImageName string
	Cpus      float32
	Memory    string
}

NativeDockerConfig native contract use docker config

type NodeConfig

type NodeConfig struct {
	Version         string          `yaml:"version,omitempty"`
	Log             LogConfig       `yaml:"log,omitempty"`
	TCPServer       TCPServerConfig `yaml:"tcpServer,omitempty"`
	P2pV2           P2PConfig       `yaml:"p2pV2,omitempty"`
	Miner           MinerConfig     `yaml:"miner,omitempty"`
	Datapath        string          `yaml:"datapath,omitempty"`
	DatapathOthers  []string        `yaml:"datapathOthers,omitempty"` //扩展盘的路径
	ConsoleConfig   ConsoleConfig
	Utxo            UtxoConfig      `yaml:"utxo,omitempty"`
	DedupCacheSize  int             `yaml:"dedupCacheSize,omitempty"`
	DedupTimeLimit  int             `yaml:"dedupTimeLimit,omitempty"`
	Kernel          KernelConfig    `yaml:"kernel,omitempty"`
	FeeConfig       FeeConfig       `yaml:"feeConfig,omitempty"`
	CPUProfile      string          `yaml:"cpuprofile,omitempty"`
	MemProfile      string          `yaml:"memprofile,omitempty"`
	MemberWhiteList map[string]bool `yaml:"memberWhiteList,omitempty"`
	Native          NativeConfig    `yaml:"native,omitempty"`
	DBCache         DBCacheConfig   `yaml:"dbcache,omitempty"`
	// 节点模式: NORMAL | FAST_SYNC 两种模式
	// NORMAL: 为普通的全节点模式
	// FAST_SYNC 模式下:节点需要连接一个可信的全节点; 拒绝事务提交; 同步区块时跳过块验证和tx验证; 去掉load未确认事务;
	NodeMode        string     `yaml:"nodeMode,omitempty"`
	PluginConfPath  string     `yaml:"pluginConfPath,omitempty"`
	EtcdClusterAddr string     `yaml:"etcdClusterAddr,omitempty"`
	GatewaySwitch   bool       `yaml:"gatewaySwitch,omitempty"`
	Wasm            WasmConfig `yaml:"wasm,omitempty"`
	CoreConnection  bool       `yaml:"coreConnection,omitempty"`
}

NodeConfig is the main config of the AmpChain node

func NewNodeConfig

func NewNodeConfig() *NodeConfig

NewNodeConfig returns a config of a node

func (*NodeConfig) ApplyFlags

func (nc *NodeConfig) ApplyFlags(flags *pflag.FlagSet)

ApplyFlags install flags and use flags to overwrite config file

func (*NodeConfig) LoadConfig

func (nc *NodeConfig) LoadConfig()

LoadConfig load config from config file

func (*NodeConfig) Validate

func (nc *NodeConfig) Validate() error

Validate valid if

func (*NodeConfig) VisitAll

func (nc *NodeConfig) VisitAll()

VisitAll print all config of node

type P2PConfig

type P2PConfig struct {
	// port the p2p network listened
	Port int32 `yaml:"port,omitempty"`
	// keyPath is the node private key path, amper will gen a random one if is nil
	KeyPath string `yaml:"keyPath,omitempty"`
	// isNat config whether the node use NAT manager
	IsNat bool `yaml:"isNat,omitempty"`
	// isSecure config whether the node use secure transparent
	IsSecure bool `yaml:"isSecure,omitempty"`
	// isHidden config whether the node can be found
	IsHidden bool `yaml:"isHidden,omitempty"`
	// bootNodes config the bootNodes the node to connect
	BootNodes []string `yaml:"bootNodes,omitempty"`
	// staticNodes config the nodes which you trust
	StaticNodes []string `yaml:"staticNodes,omitempty"`
	// maxStreamLimits config the max stream num
	MaxStreamLimits int32 `yaml:"maxStreamLimits,omitempty"`
	// maxMessageSize config the max message size
	MaxMessageSize int64 `yaml:"maxMessageSize,omitempty"`
	// timeout config the timeout of Request with response
	Timeout int64 `yaml:"timeout,omitempty"`
	// IsAuthentication determine whether peerID and AChain addr correspond
	IsAuthentication bool `yaml:"isauthentication,omitempty"`
	// StreamIPLimitSize set the limitation size for same ip
	StreamIPLimitSize int64 `yaml:"streamIPLimitSize,omitempty"`
}

P2PConfig is the config of amper p2p server. Attention, config of dht are not expose

type TCPServerConfig

type TCPServerConfig struct {
	Port                  string `yaml:"port,omitempty"`
	HTTPSPort             string `yaml:"httpsPort,omitempty"`
	MetricPort            string `yaml:"metricPort,omitempty"`
	MaxMsgSize            int    `yaml:"maxmsgsize,omitempty"`
	TLS                   bool   `yaml:"tls,omitempty"`
	TLSPath               string `yaml:"tlsPath,omitempty"`
	MServerURL            string `yaml:"mServerUrl,omitempty"`
	MServerName           string `yaml:"mServerName,omitempty"`
	CachePeriod           int64  `yaml:"cachePeriod,omitempty"`
	InitialWindowSize     int32  `yaml:"initialWindowSize,omitempty"`
	InitialConnWindowSize int32  `yaml:"initialConnWindowSize"`
	ReadBufferSize        int    `yaml:"readBufferSize"`
	WriteBufferSize       int    `yaml:"writeBufferSize"`
}

TCPServerConfig is the tcp port of the node

type UtxoConfig

type UtxoConfig struct {
	// nonUtxo 是否支持utxo无币化
	NonUtxo               bool                       `yaml:"nonUtxo,omitempty"`
	CacheSize             int                        `yaml:"cachesize,omitempty"`
	TmpLockSeconds        int                        `yaml:"tmplockSeconds,omitempty"`
	AsyncMode             bool                       `yaml:"asyncMode,omitempty"`
	ContractExecutionTime int                        `yaml:"contractExecutionTime,omitempty"`
	ContractWhiteList     map[string]map[string]bool `yaml:"contractWhiteList,omitempty"`
	// 是否开启新版本tx k = bcname, v = isBetaTx
	IsBetaTx          map[string]bool `yaml:"isBetaTx,omitempty"`
	MaxConfirmedDelay uint32          `yaml:"maxConfirmedDelay,omitempty"`
}

UtxoConfig is the config of UtxoVM

type WasmConfig

type WasmConfig struct {
	Driver         string
	External       bool
	XVM            XVMConfig
	EnableDebugLog bool
	DebugLog       LogConfig
}

WasmConfig wasm config

type XVMConfig

type XVMConfig struct {
	// From 0 to 3
	// The higher the number, the faster the program runs,
	// but the compilation speed will be slower
	OptLevel int `yaml:"optlevel"`
}

XVMConfig contains the xvm configuration

Jump to

Keyboard shortcuts

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