Documentation ¶
Index ¶
- Constants
- Variables
- func DoNotValidate(cfg *Config) error
- func ValidateActPool(cfg *Config) error
- func ValidateChain(cfg *Config) error
- func ValidateConsensusScheme(cfg *Config) error
- func ValidateDispatcher(cfg *Config) error
- func ValidateExplorer(cfg *Config) error
- func ValidateKeyPair(cfg *Config) error
- func ValidateNetwork(cfg *Config) error
- func ValidateRollDPoS(cfg *Config) error
- type ActPool
- type BlockSync
- type Chain
- type Config
- type Consensus
- type DB
- type Dispatcher
- type Explorer
- type Indexer
- type Network
- type RDS
- type RollDPoS
- type System
- type Validate
Constants ¶
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 ¶
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", ID: 1, Address: "", ProducerPubKey: keypair.EncodePublicKey(keypair.ZeroPublicKey), ProducerPrivKey: keypair.EncodePrivateKey(keypair.ZeroPrivateKey), InMemTest: false, GenesisActionsPath: "", EmptyGenesis: false, NumCandidates: 101, EnableFallBackToFreshDB: false, EnableSubChainStartInGenesis: false, EnableGasCharge: 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, AcceptProposalEndorseTTL: time.Second, AcceptCommitEndorseTTL: time.Second, Delay: 5 * time.Second, NumSubEpochs: 1, EventChanSize: 10000, NumDelegates: 21, TimeBasedRotation: false, EnableDKG: false, }, BlockCreationInterval: 10 * time.Second, }, BlockSync: BlockSync{ Interval: 10 * time.Second, BufferSize: 16, }, Dispatcher: Dispatcher{ EventChanSize: 10000, }, Explorer: Explorer{ Enabled: false, UseRDS: false, Port: 14004, TpsWindow: 10, MaxTransferPayloadBytes: 1024, }, Indexer: Indexer{ Enabled: false, NodeAddr: "", }, System: System{ HeartbeatInterval: 10 * time.Second, HTTPProfilingPort: 0, HTTPMetricsPort: 8080, StartSubChainInterval: 10 * time.Second, }, DB: DB{ NumRetries: 3, }, } // ErrInvalidCfg indicates the invalid config value ErrInvalidCfg = errors.New("invalid config value") // Validates is the collection config validation functions Validates = []Validate{ ValidateKeyPair, ValidateConsensusScheme, ValidateRollDPoS, ValidateDispatcher, ValidateExplorer, ValidateNetwork, ValidateActPool, ValidateChain, } )
Functions ¶
func DoNotValidate ¶ added in v0.3.0
DoNotValidate validates the given config
func ValidateActPool ¶ added in v0.3.0
ValidateActPool validates the given config
func ValidateChain ¶ added in v0.3.0
ValidateChain validates the chain configure
func ValidateConsensusScheme ¶ added in v0.3.0
ValidateConsensusScheme validates the if scheme and node type match
func ValidateDispatcher ¶ added in v0.3.0
ValidateDispatcher validates the dispatcher configs
func ValidateExplorer ¶ added in v0.3.0
ValidateExplorer validates the explorer configs
func ValidateKeyPair ¶ added in v0.4.0
ValidateKeyPair validates the block producer address
func ValidateNetwork ¶ added in v0.3.0
ValidateNetwork validates the network configs
func ValidateRollDPoS ¶ added in v0.3.0
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"` ID uint32 `yaml:"id"` Address string `yaml:"address"` 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"` EmptyGenesis bool `yaml:"emptyGenesis"` NumCandidates uint `yaml:"numCandidates"` EnableFallBackToFreshDB bool `yaml:"enableFallbackToFreshDb"` EnableSubChainStartInGenesis bool `yaml:"enableSubChainStartInGenesis"` // enable gas charge for block producer EnableGasCharge bool `yaml:"enableGasCharge"` }
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"` Indexer Indexer `yaml:"indexer"` System System `yaml:"system"` DB DB `yaml:"db"` }
Config is the root config struct, each package's config should be put as its sub struct
func New ¶ added in v0.3.0
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) BlockchainAddress ¶ added in v0.4.0
BlockchainAddress returns the address derived from the configured chain ID and public key
func (*Config) IsDelegate ¶
IsDelegate returns true if the node type is Delegate
func (*Config) IsFullnode ¶
IsFullnode returns true if the node type is Fullnode
func (*Config) IsLightweight ¶
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 DB ¶ added in v0.4.0
type DB struct { // NumRetries is the number of retries NumRetries uint8 `yaml:"numRetries"` // RDS is the config fot rds RDS RDS `yaml:"RDS"` }
DB is the blotDB config
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"` UseRDS bool `yaml:"useRDS"` Port int `yaml:"port"` 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 RDS ¶ added in v0.4.0
type RDS struct { // AwsRDSEndpoint is the endpoint of aws rds AwsRDSEndpoint string `yaml:"awsRDSEndpoint"` // AwsRDSPort is the port of aws rds AwsRDSPort uint64 `yaml:"awsRDSPort"` // AwsRDSUser is the user to access aws rds AwsRDSUser string `yaml:"awsRDSUser"` // AwsPass is the pass to access aws rds AwsPass string `yaml:"awsPass"` // AwsDBName is the db name of aws rds AwsDBName string `yaml:"awsDBName"` }
RDS is the cloud rds config
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"` AcceptProposalEndorseTTL time.Duration `yaml:"acceptProposalEndorseTTL"` AcceptCommitEndorseTTL time.Duration `yaml:"acceptCommitEndorseTTL"` Delay time.Duration `yaml:"delay"` NumSubEpochs uint `yaml:"numSubEpochs"` EventChanSize uint `yaml:"eventChanSize"` NumDelegates uint `yaml:"numDelegates"` TimeBasedRotation bool `yaml:"timeBasedRotation"` EnableDKG bool `yaml:"enableDKG"` }
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"` HTTPMetricsPort int `yaml:"httpMetricsPort"` StartSubChainInterval time.Duration `yaml:"startSubChainInterval"` }
System is the system config