config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

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"
)
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 (
	// DefaultConfigPath is the default config path
	DefaultConfigPath = "./config.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockSync

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

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"`
	// ProducerAddr is an iotxaddress struct constructed from ProducerPubKey and ProducerPrivKey
	ProducerAddr iotxaddress.Address `yaml:"producerAddr"`

	// InMemTest creates in-memory DB file for local testing
	InMemTest          bool   `yaml:"inMemTest"`
	GenesisActionsPath string `yaml:"genesisActionsPath"`
}

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"`
	Consensus  Consensus  `yaml:"consensus"`
	Delegate   Delegate   `yaml:"delegate"`
	RPC        RPC        `yaml:"rpc"`
	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 LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the config instance from the default config path

func LoadConfigWithPath

func LoadConfigWithPath(path string) (*Config, error)

LoadConfigWithPath loads the config instance and validates fields

func LoadConfigWithPathWithoutValidation

func LoadConfigWithPathWithoutValidation(path string) (*Config, error)

LoadConfigWithPathWithoutValidation loads the config instance but doesn't validate fields

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

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 Delegate

type Delegate struct {
	Addrs   []string `yaml:"addrs"`
	RollNum uint     `yaml:"rollNum"`
}

Delegate is the delegate config

type Dispatcher

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

Dispatcher is the dispatcher config

type Explorer

type Explorer struct {
	Enabled   bool   `yaml:"enabled"`
	IsTest    bool   `yaml:"isTest"`
	Addr      string `yaml:"addr"`
	TpsWindow int    `yaml:"tpsWindow"`
}

Explorer is the explorer service config

type Network

type Network struct {
	Addr                    string                      `yaml:"addr"`
	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"`
	AllowMultiConnsPerIP    bool                        `yaml:"allowMultiConnsPerIP"`
	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                     uint32                      `yaml:"ttl"`
}

Network is the config struct for network package

type RPC

type RPC struct {
	Addr string `yaml:"addr"`
}

RPC is the chain service config

type RollDPoS

type RollDPoS struct {
	DelegateInterval  time.Duration `yaml:"delegateInterval"`
	ProposerInterval  time.Duration `yaml:"proposerInterval"`
	ProposerCB        string        `yaml:"proposerCB"`
	EpochCB           string        `yaml:"epochCB"`
	UnmatchedEventTTL time.Duration `yaml:"unmatchedEventTTL"`
	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"`
}

RollDPoS is the config struct for RollDPoS consensus package

type System

type System struct {
	HeartbeatInterval time.Duration `yaml:"heartbeatInterval"`
}

System is the system config

type Topology

type Topology struct {
	NeighborList map[string][]string `yaml:"neighborList"`
}

Topology is the neighbor list for each node. This is used for generating the P2P network in a given topology. Note that the list contains the outgoing connections.

func LoadTopology

func LoadTopology(path string) (*Topology, error)

LoadTopology loads the topology struct from the given yaml file

Jump to

Keyboard shortcuts

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