config

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

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,
		ActionSync: actsync.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

func DoNotValidate(cfg Config) error

DoNotValidate validates the given config

func ValidateAPI

func ValidateAPI(cfg Config) error

ValidateAPI validates the api configs

func ValidateActPool

func ValidateActPool(cfg Config) error

ValidateActPool validates the given config

func ValidateArchiveMode

func ValidateArchiveMode(cfg Config) error

ValidateArchiveMode validates the state factory setting

func ValidateDispatcher

func ValidateDispatcher(cfg Config) error

ValidateDispatcher validates the dispatcher configs

func ValidateForkHeights

func ValidateForkHeights(cfg Config) error

ValidateForkHeights validates the forked heights

func ValidateRollDPoS

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"`
	ActionSync         actsync.Config                  `yaml:"actionSync"`
}

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

func New

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

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

NewSub create config for sub chain.

type System

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

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