config

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 18 Imported by: 44

Documentation

Index

Constants

View Source
const (
	// RollDPoSScheme means randomized delegated proof of stake
	RollDPoSScheme = "ROLLDPOS"
	// StandaloneScheme means that the node creates a block periodically regardless of others (if there is any)
	StandaloneScheme = "STANDALONE"
	// NOOPScheme means that the node does not create only block
	NOOPScheme = "NOOP"
)
View Source
const (
	// GatewayPlugin is the plugin of accepting user API requests and serving blockchain data to users
	GatewayPlugin = iota
)

Variables

View Source
var (
	// Default is the default config
	Default = Config{
		Plugins:            make(map[int]interface{}),
		SubLogs:            make(map[string]log.GlobalConfig),
		Network:            p2p.DefaultConfig,
		Chain:              blockchain.DefaultConfig,
		ActPool:            actpool.DefaultConfig,
		Consensus:          consensus.DefaultConfig,
		DardanellesUpgrade: consensusfsm.DefaultDardanellesUpgradeConfig,
		BlockSync:          blocksync.DefaultConfig,
		Dispatcher:         dispatcher.DefaultConfig,
		API:                api.DefaultConfig,
		System: System{
			Active:                true,
			HeartbeatInterval:     10 * time.Second,
			HTTPStatsPort:         8080,
			HTTPAdminPort:         0,
			StartSubChainInterval: 10 * time.Second,
			SystemLogDBPath:       "/var/log",
		},
		DB:       db.DefaultConfig,
		Indexer:  blockindex.DefaultConfig,
		Genesis:  genesis.Default,
		NodeInfo: nodeinfo.DefaultConfig,
	}

	// ErrInvalidCfg indicates the invalid config value
	ErrInvalidCfg = errors.New("invalid config value")

	// Validates is the collection config validation functions
	Validates = []Validate{
		ValidateRollDPoS,
		ValidateArchiveMode,
		ValidateDispatcher,
		ValidateAPI,
		ValidateActPool,
		ValidateForkHeights,
	}
)

Dardanelles consensus config

Functions

func DoNotValidate added in v0.3.0

func DoNotValidate(cfg Config) error

DoNotValidate validates the given config

func ValidateAPI added in v0.5.0

func ValidateAPI(cfg Config) error

ValidateAPI validates the api configs

func ValidateActPool added in v0.3.0

func ValidateActPool(cfg Config) error

ValidateActPool validates the given config

func ValidateArchiveMode added in v0.11.0

func ValidateArchiveMode(cfg Config) error

ValidateArchiveMode validates the state factory setting

func ValidateDispatcher added in v0.3.0

func ValidateDispatcher(cfg Config) error

ValidateDispatcher validates the dispatcher configs

func ValidateForkHeights added in v1.1.0

func ValidateForkHeights(cfg Config) error

ValidateForkHeights validates the forked heights

func ValidateRollDPoS added in v0.3.0

func ValidateRollDPoS(cfg Config) error

ValidateRollDPoS validates the roll-DPoS configs

Types

type Config

type Config struct {
	Plugins            map[int]interface{}             `ymal:"plugins"`
	Network            p2p.Config                      `yaml:"network"`
	Chain              blockchain.Config               `yaml:"chain"`
	ActPool            actpool.Config                  `yaml:"actPool"`
	Consensus          consensus.Config                `yaml:"consensus"`
	DardanellesUpgrade consensusfsm.DardanellesUpgrade `yaml:"dardanellesUpgrade"`
	BlockSync          blocksync.Config                `yaml:"blockSync"`
	Dispatcher         dispatcher.Config               `yaml:"dispatcher"`
	API                api.Config                      `yaml:"api"`
	System             System                          `yaml:"system"`
	DB                 db.Config                       `yaml:"db"`
	Indexer            blockindex.Config               `yaml:"indexer"`
	Log                log.GlobalConfig                `yaml:"log"`
	SubLogs            map[string]log.GlobalConfig     `yaml:"subLogs"`
	Genesis            genesis.Genesis                 `yaml:"genesis"`
	NodeInfo           nodeinfo.Config                 `yaml:"nodeinfo"`
}

Config is the root config struct, each package's config should be put as its sub struct

func New added in v0.3.0

func New(configPaths []string, _plugins []string, validates ...Validate) (Config, error)

New creates a config instance. It first loads the default configs. If the config path is not empty, it will read from the file and override the default configs. By default, it will apply all validation functions. To bypass validation, use DoNotValidate instead.

func NewSub added in v0.4.0

func NewSub(configPaths []string, validates ...Validate) (Config, error)

NewSub create config for sub chain.

type System added in v0.2.0

type System struct {
	// Active is the status of the node. True means active and false means stand-by
	Active            bool          `yaml:"active"`
	HeartbeatInterval time.Duration `yaml:"heartbeatInterval"`
	// HTTPProfilingPort is the port number to access golang performance profiling data of a blockchain node. It is
	// 0 by default, meaning performance profiling has been disabled
	HTTPAdminPort         int           `yaml:"httpAdminPort"`
	HTTPStatsPort         int           `yaml:"httpStatsPort"`
	StartSubChainInterval time.Duration `yaml:"startSubChainInterval"`
	SystemLogDBPath       string        `yaml:"systemLogDBPath"`
	MptrieLogPath         string        `yaml:"mptrieLogPath"`
}

System is the system config

type Validate added in v0.3.0

type Validate func(Config) error

Validate is the interface of validating the config

Jump to

Keyboard shortcuts

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