config

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MIT Imports: 3 Imported by: 31

Documentation

Index

Constants

View Source
const (
	EnvironmentPrefix = "AG"
)

Config should be read-only in outer world, but golang doesn't have any simple solution for that. A Developer MUST NOT modify config value in caller code.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountConfig added in v0.9.0

type AccountConfig struct {
	UnlockTimeout uint `mapstructure:"unlocktimeout" description:"lock automatically after timeout (sec)"`
}

Account defines configurations for account service

type BaseConfig

type BaseConfig struct {
	DataDir        string `mapstructure:"datadir" description:"Directory to store datafiles"`
	DbType         string `mapstructure:"dbtype" description:"db implementation to store data"`
	EnableProfile  bool   `mapstructure:"enableprofile" description:"enable profiling"`
	ProfilePort    int    `mapstructure:"profileport" description:"profiling port (default:6060)"`
	EnableTestmode bool   `mapstructure:"enabletestmode" description:"enable unsafe test mode"`
	UseTestnet     bool   `mapstructure:"usetestnet" description:"need description"`
	Personal       bool   `mapstructure:"personal" description:"enable personal account service"`
	AuthDir        string `mapstructure:"authdir" description:"Directory to store files for auth"`
}

BaseConfig defines base configurations for aergo server

type BlockchainConfig

type BlockchainConfig struct {
	MaxBlockSize     uint32 `mapstructure:"maxblocksize"  description:"maximum block size in bytes"`
	CoinbaseAccount  string `mapstructure:"coinbaseaccount" description:"wallet address for coinbase"`
	MaxAnchorCount   int    `mapstructure:"maxanchorcount" description:"maximun anchor count for sync"`
	VerifierCount    int    `mapstructure:"verifiercount" description:"maximun transaction verifier count"`
	ForceResetHeight uint64 `mapstructure:"forceresetheight" description:"best height to reset chain manually"`
	ZeroFee          bool   `mapstructure:"zerofee" description:"enable zero-fee mode(works only on private network)"`
}

BlockchainConfig defines configurations for blockchain service

type Config

type Config struct {
	BaseConfig `mapstructure:",squash"`
	RPC        *RPCConfig        `mapstructure:"rpc"`
	P2P        *P2PConfig        `mapstructure:"p2p"`
	Polaris    *PolarisConfig    `mapstructure:"polaris"`
	Blockchain *BlockchainConfig `mapstructure:"blockchain"`
	Mempool    *MempoolConfig    `mapstructure:"mempool"`
	Consensus  *ConsensusConfig  `mapstructure:"consensus"`
	Monitor    *MonitorConfig    `mapstructure:"monitor"`
	Account    *AccountConfig    `mapstructure:"account"`
}

Config defines configurations of each services

type ConsensusConfig

type ConsensusConfig struct {
	EnableBp      bool        `mapstructure:"enablebp" description:"enable block production"`
	BlockInterval int64       `mapstructure:"blockinterval" description:"block production interval (sec)"`
	Raft          *RaftConfig `mapstructure:"raft"`
}

ConsensusConfig defines configurations for consensus service

type MempoolConfig

type MempoolConfig struct {
	ShowMetrics    bool   `mapstructure:"showmetrics" description:"show mempool metric periodically"`
	EnableFadeout  bool   `mapstructure:"enablefadeout" description:"Enable transaction fadeout over timeout period"`
	FadeoutPeriod  int    `mapstructure:"fadeoutperiod" description:"time period for evict transactions(in hour)"`
	VerifierNumber int    `mapstructure:"verifiers" description:"number of concurrent verifier"`
	DumpFilePath   string `mapstructure:"dumpfilepath" description:"file path for recording mempool at process termintation"`
}

MempoolConfig defines configurations for mempool service

type MonitorConfig added in v0.8.1

type MonitorConfig struct {
	ServerProtocol string `mapstructure:"protocol" description:"Protocol is one of next: http, https or kafka"`
	ServerEndpoint string `mapstructure:"endpoint" description:"Endpoint to send"`
}

type P2PConfig

type P2PConfig struct {
	// N2N (peer-to-peer) network
	NetProtocolAddr string   `` /* 139-byte string literal not displayed */
	NetProtocolPort int      `` /* 133-byte string literal not displayed */
	NPBindAddr      string   `mapstructure:"npbindaddr" description:"N2N bind address. If it was set, it only accept connection to this addresse only"`
	NPBindPort      int      `` /* 161-byte string literal not displayed */
	NPEnableTLS     bool     `mapstructure:"nptls" description:"Enable TLS on N2N network"`
	NPCert          string   `mapstructure:"npcert" description:"Certificate file for N2N network"`
	NPKey           string   `mapstructure:"npkey" description:"Private Key file for N2N network"`
	NPAddPeers      []string `mapstructure:"npaddpeers" description'':"Add peers to connect to at startup"`
	NPHiddenPeers   []string `mapstructure:"nphiddenpeers" description:"List of peerids which will not show to other peers"`
	NPDiscoverPeers bool     `mapstructure:"npdiscoverpeers" description:"Whether to discover from polaris or other nodes and connects"`
	NPMaxPeers      int      `mapstructure:"npmaxpeers" description:"Maximum number of remote peers to keep"`
	NPPeerPool      int      `mapstructure:"nppeerpool" description:"Max peer pool size"`

	NPExposeSelf   bool     `mapstructure:"npexposeself" description:"Whether to request expose self to polaris and other connected node"`
	NPUsePolaris   bool     `mapstructure:"npusepolaris" description:"Whether to connect and get node list from polaris"`
	NPAddPolarises []string `mapstructure:"npaddpolarises" description:"Add addresses of polarises if default polaris is not sufficient"`

	LogFullPeerID bool `mapstructure:"logfullpeerid" description:"Whether to use full legnth peerID or short form"`
}

P2PConfig defines configurations for p2p service

type PolarisConfig added in v0.9.0

type PolarisConfig struct {
	AllowPrivate bool   `mapstructure:"allowprivate" description:"allow peer to have private address. for private network and test"`
	GenesisFile  string `mapstructure:"genesisfile" description:"json file containing informations of genesisblock to which polaris refer "`
}

PolarisConfig defines configuration for polaris server and client (i.e. polarisConnect)

type RPCConfig

type RPCConfig struct {
	// RPC and REST
	NetServiceAddr  string `mapstructure:"netserviceaddr" description:"RPC service address"`
	NetServicePort  int    `mapstructure:"netserviceport" description:"RPC service port"`
	NetServiceTrace bool   `mapstructure:"netservicetrace" description:"Trace RPC service"`
	// RPC API with TLS
	NSEnableTLS bool   `mapstructure:"nstls" description:"Enable TLS on RPC or REST API"`
	NSCert      string `mapstructure:"nscert" description:"Certificate file for RPC or REST API"`
	NSKey       string `mapstructure:"nskey" description:"Private Key file for RPC or REST API"`
	NSAllowCORS bool   `mapstructure:"nsallowcors" description:"Allow CORS to RPC or REST API"`
}

RPCConfig defines configurations for rpc service

type RaftBPConfig added in v0.9.0

type RaftBPConfig struct {
	Name  string `mapstructure:"name" description:"raft node name"`
	Url   string `mapstructure:"url" description:"raft url"`
	P2pID string `mapstructure:"p2pid" description:"p2p ID of this bp"`
}

type RaftConfig added in v0.9.0

type RaftConfig struct {
	Name          string         `mapstructure:"name" description:"raft node name. this value must be unique in cluster"`
	ListenUrl     string         `mapstructure:"listenurl" description:"raft http bind address. If it was set, it only accept connection to this addresse only"`
	BPs           []RaftBPConfig `mapstructure:"bps"`
	SkipEmpty     bool           `mapstructure:"skipempty" description:"skip producing block if there is no tx in block"`
	KeyFile       string         `mapstructure:"keyfile" description:"Private Key file for raft https server"`
	CertFile      string         `mapstructure:"certfile" description:"Certificate file for raft https server"`
	Tick          uint           `mapstructure:"tick" description:"tick of raft server (millisec)"`
	BPIntervalMs  int64          `mapstructure:"bpintervalms" description:"block interval for raft (millisec)"`
	BPTimeoutMs   int64          `mapstructure:"bptimeoutms" description:"block timeout for raft (millisec)"`
	NewCluster    bool           `mapstructure:"newcluster" description:"create a new raft cluster if it doesn't already exist"`
	SnapFrequency uint64         `mapstructure:"snapfrequency" description:"frequency which raft make snapshot with log"`
}

type ServerContext

type ServerContext struct {
	config.BaseContext
}

func NewServerContext

func NewServerContext(homePath string, configFilePath string) *ServerContext

func (*ServerContext) GetConfigFileName

func (ctx *ServerContext) GetConfigFileName() string

func (*ServerContext) GetDefaultAccountConfig added in v0.9.0

func (ctx *ServerContext) GetDefaultAccountConfig() *AccountConfig

func (*ServerContext) GetDefaultBaseConfig

func (ctx *ServerContext) GetDefaultBaseConfig() BaseConfig

func (*ServerContext) GetDefaultBlockchainConfig

func (ctx *ServerContext) GetDefaultBlockchainConfig() *BlockchainConfig

func (*ServerContext) GetDefaultConfig

func (ctx *ServerContext) GetDefaultConfig() interface{}

func (*ServerContext) GetDefaultConsensusConfig

func (ctx *ServerContext) GetDefaultConsensusConfig() *ConsensusConfig

func (*ServerContext) GetDefaultMempoolConfig

func (ctx *ServerContext) GetDefaultMempoolConfig() *MempoolConfig

func (*ServerContext) GetDefaultMonitorConfig added in v0.8.1

func (ctx *ServerContext) GetDefaultMonitorConfig() *MonitorConfig

func (*ServerContext) GetDefaultP2PConfig

func (ctx *ServerContext) GetDefaultP2PConfig() *P2PConfig

func (*ServerContext) GetDefaultPolarisConfig added in v0.9.0

func (ctx *ServerContext) GetDefaultPolarisConfig() *PolarisConfig

func (*ServerContext) GetDefaultRPCConfig

func (ctx *ServerContext) GetDefaultRPCConfig() *RPCConfig

func (*ServerContext) GetHomePath

func (ctx *ServerContext) GetHomePath() string

func (*ServerContext) GetTemplate

func (ctx *ServerContext) GetTemplate() string

Jump to

Keyboard shortcuts

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