config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: Apache-2.0 Imports: 9 Imported by: 44

Documentation

Index

Constants

View Source
const (
	// DelegateType represents the delegate node type
	DelegateType = "delegate"
	// FullNodeType represents the full node type
	FullNodeType = "full_node"
	// LightweightType represents the lightweight type
	LightweightType = "lightweight"

	// 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"
)

Variables

View Source
var (
	// Default is the default config
	Default = Config{
		NodeType: FullNodeType,
		Network: Network{
			Host:                                "127.0.0.1",
			Port:                                4689,
			MsgLogsCleaningInterval:             2 * time.Second,
			MsgLogRetention:                     5 * time.Second,
			HealthCheckInterval:                 time.Second,
			SilentInterval:                      5 * time.Second,
			PeerMaintainerInterval:              time.Second,
			PeerForceDisconnectionRoundInterval: 0,
			AllowMultiConnsPerHost:              false,
			NumPeersLowerBound:                  5,
			NumPeersUpperBound:                  5,
			PingInterval:                        time.Second,
			RateLimitEnabled:                    false,
			RateLimitPerSec:                     10000,
			RateLimitWindowSize:                 60 * time.Second,
			BootstrapNodes:                      make([]string, 0),
			TLSEnabled:                          false,
			CACrtPath:                           "",
			PeerCrtPath:                         "",
			PeerKeyPath:                         "",
			KLClientParams:                      keepalive.ClientParameters{},
			KLServerParams:                      keepalive.ServerParameters{},
			KLPolicy:                            keepalive.EnforcementPolicy{},
			MaxMsgSize:                          10485760,
			PeerDiscovery:                       true,
			TopologyPath:                        "",
			TTL:                                 3,
		},
		Chain: Chain{
			ChainDBPath:             "/tmp/chain.db",
			TrieDBPath:              "/tmp/trie.db",
			ProducerPubKey:          keypair.EncodePublicKey(keypair.ZeroPublicKey),
			ProducerPrivKey:         keypair.EncodePrivateKey(keypair.ZeroPrivateKey),
			InMemTest:               false,
			GenesisActionsPath:      "",
			DelegateLRUSize:         10,
			NumCandidates:           101,
			EnableFallBackToFreshDB: false,
		},
		ActPool: ActPool{
			MaxNumActsPerPool: 32000,
			MaxNumActsPerAcct: 2000,
			MaxNumActsToPick:  0,
		},
		Consensus: Consensus{
			Scheme: NOOPScheme,
			RollDPoS: RollDPoS{
				DelegateInterval:       10 * time.Second,
				ProposerInterval:       10 * time.Second,
				UnmatchedEventTTL:      3 * time.Second,
				UnmatchedEventInterval: 100 * time.Millisecond,
				RoundStartTTL:          10 * time.Second,
				AcceptProposeTTL:       time.Second,
				AcceptPrevoteTTL:       time.Second,
				AcceptVoteTTL:          time.Second,
				Delay:                  5 * time.Second,
				NumSubEpochs:           1,
				EventChanSize:          10000,
				NumDelegates:           21,
				EnableDummyBlock:       true,
			},
			BlockCreationInterval: 10 * time.Second,
		},
		BlockSync: BlockSync{
			Interval:   10 * time.Second,
			BufferSize: 16,
		},

		Dispatcher: Dispatcher{
			EventChanSize: 10000,
		},
		Explorer: Explorer{
			Enabled:                 true,
			IsTest:                  false,
			Port:                    14004,
			TpsWindow:               10,
			MaxTransferPayloadBytes: 1024,
		},
		System: System{
			HeartbeatInterval: 10 * time.Second,
			HTTPProfilingPort: 0,
		},
	}

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

	// Validates is the collection config validation functions
	Validates = []Validate{
		ValidateAddr,
		ValidateConsensusScheme,
		ValidateRollDPoS,
		ValidateDispatcher,
		ValidateExplorer,
		ValidateNetwork,
		ValidateActPool,
		ValidateChain,
	}
)

Functions

func DoNotValidate added in v0.3.0

func DoNotValidate(cfg *Config) error

DoNotValidate validates the given config

func ValidateActPool added in v0.3.0

func ValidateActPool(cfg *Config) error

ValidateActPool validates the given config

func ValidateAddr added in v0.3.0

func ValidateAddr(cfg *Config) error

ValidateAddr validates the block producer address

func ValidateChain added in v0.3.0

func ValidateChain(cfg *Config) error

ValidateChain validates the chain configure

func ValidateConsensusScheme added in v0.3.0

func ValidateConsensusScheme(cfg *Config) error

ValidateConsensusScheme validates the if scheme and node type match

func ValidateDispatcher added in v0.3.0

func ValidateDispatcher(cfg *Config) error

ValidateDispatcher validates the dispatcher configs

func ValidateExplorer added in v0.3.0

func ValidateExplorer(cfg *Config) error

ValidateExplorer validates the explorer configs

func ValidateNetwork added in v0.3.0

func ValidateNetwork(cfg *Config) error

ValidateNetwork validates the network configs

func ValidateRollDPoS added in v0.3.0

func ValidateRollDPoS(cfg *Config) error

ValidateRollDPoS validates the roll-DPoS configs

Types

type ActPool added in v0.3.0

type ActPool struct {
	// MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold
	MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"`
	// MaxNumActsPerAcct indicates maximum number of actions an account queue can hold
	MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"`
	// MaxNumActsToPick indicates maximum number of actions to pick to mint a block. Default is 0, which means no
	// limit on the number of actions to pick.
	MaxNumActsToPick uint64 `yaml:"maxNumActsToPick"`
}

ActPool is the actpool config

type BlockSync added in v0.2.0

type BlockSync struct {
	Interval   time.Duration `yaml:"interval"` // update duration
	BufferSize uint64        `yaml:"bufferSize"`
}

BlockSync is the config struct for the BlockSync

type Chain

type Chain struct {
	ChainDBPath string `yaml:"chainDBPath"`
	TrieDBPath  string `yaml:"trieDBPath"`

	ProducerPubKey  string `yaml:"producerPubKey"`
	ProducerPrivKey string `yaml:"producerPrivKey"`

	// InMemTest creates in-memory DB file for local testing
	InMemTest               bool   `yaml:"inMemTest"`
	GenesisActionsPath      string `yaml:"genesisActionsPath"`
	DelegateLRUSize         uint   `yaml:"delegateLRUSize"`
	NumCandidates           uint   `yaml:"numCandidates"`
	EnableFallBackToFreshDB bool   `yaml:"enablefallbacktofreshdb"`
}

Chain is the config struct for blockchain package

type Config

type Config struct {
	NodeType   string     `yaml:"nodeType"`
	Network    Network    `yaml:"network"`
	Chain      Chain      `yaml:"chain"`
	ActPool    ActPool    `yaml:"actPool"`
	Consensus  Consensus  `yaml:"consensus"`
	BlockSync  BlockSync  `yaml:"blockSync"`
	Dispatcher Dispatcher `yaml:"dispatcher"`
	Explorer   Explorer   `yaml:"explorer"`
	System     System     `yaml:"system"`
}

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(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 (*Config) IsDelegate

func (cfg *Config) IsDelegate() bool

IsDelegate returns true if the node type is Delegate

func (*Config) IsFullnode

func (cfg *Config) IsFullnode() bool

IsFullnode returns true if the node type is Fullnode

func (*Config) IsLightweight

func (cfg *Config) IsLightweight() bool

IsLightweight returns true if the node type is Lightweight

func (*Config) ProducerAddr added in v0.3.0

func (cfg *Config) ProducerAddr() (*iotxaddress.Address, error)

ProducerAddr returns address struct based on the data from producer pub/pri-key in the config

type Consensus

type Consensus struct {
	// There are three schemes that are supported
	Scheme                string        `yaml:"scheme"`
	RollDPoS              RollDPoS      `yaml:"rollDPoS"`
	BlockCreationInterval time.Duration `yaml:"blockCreationInterval"`
}

Consensus is the config struct for consensus package

type Dispatcher added in v0.2.0

type Dispatcher struct {
	EventChanSize uint `yaml:"eventChanSize"`
}

Dispatcher is the dispatcher config

type Explorer added in v0.2.0

type Explorer struct {
	Enabled   bool `yaml:"enabled"`
	IsTest    bool `yaml:"isTest"`
	Port      int  `yaml:"addr"`
	TpsWindow int  `yaml:"tpsWindow"`
	// MaxTransferPayloadBytes limits how many bytes a playload can contain at most
	MaxTransferPayloadBytes uint64 `yaml:"maxTransferPayloadBytes"`
}

Explorer is the explorer service config

type Network

type Network struct {
	Host                    string        `yaml:"host"`
	Port                    int           `yaml:"port"`
	MsgLogsCleaningInterval time.Duration `yaml:"msgLogsCleaningInterval"`
	MsgLogRetention         time.Duration `yaml:"msgLogRetention"`
	HealthCheckInterval     time.Duration `yaml:"healthCheckInterval"`
	SilentInterval          time.Duration `yaml:"silentInterval"`
	PeerMaintainerInterval  time.Duration `yaml:"peerMaintainerInterval"`
	// Force disconnecting a random peer every given number of peer maintenance round
	PeerForceDisconnectionRoundInterval int                         `yaml:"peerForceDisconnectionRoundInterval"`
	AllowMultiConnsPerHost              bool                        `yaml:"allowMultiConnsPerHost"`
	NumPeersLowerBound                  uint                        `yaml:"numPeersLowerBound"`
	NumPeersUpperBound                  uint                        `yaml:"numPeersUpperBound"`
	PingInterval                        time.Duration               `yaml:"pingInterval"`
	RateLimitEnabled                    bool                        `yaml:"rateLimitEnabled"`
	RateLimitPerSec                     uint64                      `yaml:"rateLimitPerSec"`
	RateLimitWindowSize                 time.Duration               `yaml:"rateLimitWindowSize"`
	BootstrapNodes                      []string                    `yaml:"bootstrapNodes"`
	TLSEnabled                          bool                        `yaml:"tlsEnabled"`
	CACrtPath                           string                      `yaml:"caCrtPath"`
	PeerCrtPath                         string                      `yaml:"peerCrtPath"`
	PeerKeyPath                         string                      `yaml:"peerKeyPath"`
	KLClientParams                      keepalive.ClientParameters  `yaml:"klClientParams"`
	KLServerParams                      keepalive.ServerParameters  `yaml:"klServerParams"`
	KLPolicy                            keepalive.EnforcementPolicy `yaml:"klPolicy"`
	MaxMsgSize                          int                         `yaml:"maxMsgSize"`
	PeerDiscovery                       bool                        `yaml:"peerDiscovery"`
	TopologyPath                        string                      `yaml:"topologyPath"`
	TTL                                 int32                       `yaml:"ttl"`
}

Network is the config struct for network package

type RollDPoS added in v0.2.0

type RollDPoS struct {
	DelegateInterval       time.Duration `yaml:"delegateInterval"`
	ProposerInterval       time.Duration `yaml:"proposerInterval"`
	UnmatchedEventTTL      time.Duration `yaml:"unmatchedEventTTL"`
	UnmatchedEventInterval time.Duration `yaml:"unmatchedEventInterval"`
	RoundStartTTL          time.Duration `yaml:"roundStartTTL"`
	AcceptProposeTTL       time.Duration `yaml:"acceptProposeTTL"`
	AcceptPrevoteTTL       time.Duration `yaml:"acceptPrevoteTTL"`
	AcceptVoteTTL          time.Duration `yaml:"acceptVoteTTL"`
	Delay                  time.Duration `yaml:"delay"`
	NumSubEpochs           uint          `yaml:"numSubEpochs"`
	EventChanSize          uint          `yaml:"eventChanSize"`
	NumDelegates           uint          `yaml:"numDelegates"`
	EnableDummyBlock       bool          `yaml:"enableDummyBlock"`
}

RollDPoS is the config struct for RollDPoS consensus package

type System added in v0.2.0

type System struct {
	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
	HTTPProfilingPort int `yaml:"httpProfilingPort"`
}

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