config

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QlcConfigFile = "qlc.json"
)

Variables

This section is empty.

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is the default data directory to use for the databases and other persistence requirements.

func ErrToString added in v1.3.0

func ErrToString(err error) string

func QlcTestDataDir

func QlcTestDataDir() string

Types

type CfgManager added in v1.0.1

type CfgManager struct {
	ConfigFile string
	// contains filtered or unexported fields
}

func NewCfgManager

func NewCfgManager(path string) *CfgManager

func NewCfgManagerWithConfig added in v1.3.0

func NewCfgManagerWithConfig(cfgFile string, cfg *Config) *CfgManager

func NewCfgManagerWithFile added in v1.3.0

func NewCfgManagerWithFile(cfgFile string) *CfgManager

func NewCfgManagerWithName added in v1.1.1

func NewCfgManagerWithName(path string, name string) *CfgManager

func (*CfgManager) Commit added in v1.3.0

func (cm *CfgManager) Commit() error

Commit changed cfg to runtime

func (*CfgManager) CommitAndSave added in v1.3.0

func (cm *CfgManager) CommitAndSave() error

CommitAndSave commit changed cfg to runtime and save to config file

func (*CfgManager) Config added in v1.3.0

func (cm *CfgManager) Config() (*Config, error)

Config get current used config

func (*CfgManager) ConfigDir added in v1.3.0

func (cm *CfgManager) ConfigDir() string

func (*CfgManager) Diff added in v1.3.0

func (cm *CfgManager) Diff() (string, error)

Diff the changed config

func (*CfgManager) DiffOther added in v1.3.0

func (cm *CfgManager) DiffOther(cfg *Config) (string, error)

DiffOther diff runtime cfg with other `cfg`

func (*CfgManager) Discard added in v1.3.0

func (cm *CfgManager) Discard()

func (*CfgManager) Load added in v1.0.1

func (cm *CfgManager) Load(migrations ...CfgMigrate) (*Config, error)

Load the config file and will create default if config file no exist

func (*CfgManager) ParseDataDir added in v1.3.0

func (cm *CfgManager) ParseDataDir() (string, error)

ParseDataDir parse dataDir from config file

func (*CfgManager) PatchParams added in v1.3.0

func (cm *CfgManager) PatchParams(params []string, cfg *Config) (*Config, error)

func (*CfgManager) Save added in v1.3.0

func (cm *CfgManager) Save(data ...interface{}) error

Save write config to file

func (*CfgManager) UpdateParams added in v1.3.0

func (cm *CfgManager) UpdateParams(params []string) (*Config, error)

type CfgMigrate

type CfgMigrate interface {
	Migration(cfg []byte, version int) ([]byte, int, error)
	StartVersion() int
	EndVersion() int
}

type Config

type Config ConfigV5

func DefaultConfig

func DefaultConfig(dir string) (*Config, error)

func (Config) Clone added in v1.3.0

func (c Config) Clone() (*Config, error)

func (*Config) DecodePrivateKey

func (c *Config) DecodePrivateKey() (ic.PrivKey, error)

DecodePrivateKey is a helper to decode the users PrivateKey

func (*Config) LedgerDir

func (c *Config) LedgerDir() string

func (*Config) LogDir

func (c *Config) LogDir() string

func (*Config) SqliteDir added in v1.1.0

func (c *Config) SqliteDir() string

func (*Config) WalletDir

func (c *Config) WalletDir() string

type ConfigV1 added in v1.0.1

type ConfigV1 struct {
	Version             int        `json:"version"`
	DataDir             string     `json:"DataDir"`
	StorageMax          string     `json:"StorageMax"`
	Mode                string     `json:"mode"` // runtime mode: Test,Normal
	AutoGenerateReceive bool       `json:"AutoGenerateReceive"`
	LogConfig           *logConfig `json:"log"` //log config

	RPC *RPCConfigV1 `json:"rpc"`
	P2P *P2PConfigV1 `json:"p2p"`

	Discovery *DiscoveryConfigV1 `json:"Discovery"`
	ID        *IdentityConfigV1  `json:"Identity"`

	PerformanceTest *PerformanceTestConfigV1
}

func DefaultConfigV1 added in v1.0.1

func DefaultConfigV1(dir string) (*ConfigV1, error)

type ConfigV2 added in v1.0.1

type ConfigV2 struct {
	Version             int    `json:"version"`
	DataDir             string `json:"dataDir"`
	StorageMax          string `json:"storageMax"`
	AutoGenerateReceive bool   `json:"autoGenerateReceive"`
	LogLevel            string `json:"logLevel"` //info,warn,debug
	PerformanceEnabled  bool   `json:"performanceEnabled"`

	RPC *RPCConfigV2 `json:"rpc"`
	P2P *P2PConfigV2 `json:"p2p"`
}

func DefaultConfigV2 added in v1.0.1

func DefaultConfigV2(dir string) (*ConfigV2, error)

type ConfigV3 added in v1.1.0

type ConfigV3 struct {
	ConfigV2 `mapstructure:",squash"`
	DB       *DBConfig `json:"db"`
}

func DefaultConfigV3 added in v1.1.0

func DefaultConfigV3(dir string) (*ConfigV3, error)

type ConfigV4 added in v1.2.3

type ConfigV4 struct {
	ConfigV3 `mapstructure:",squash"`
	PoV      *PoVConfig `json:"pov"`
}

func DefaultConfigV4 added in v1.2.3

func DefaultConfigV4(dir string) (*ConfigV4, error)

type ConfigV5 added in v1.3.0

type ConfigV5 struct {
	ConfigV4 `mapstructure:",squash"`
	Metrics  *MetricsConfig `json:"metrics"`
	Manager  *Manager       `json:"manager"`
}

func DefaultConfigV5 added in v1.3.0

func DefaultConfigV5(dir string) (*ConfigV5, error)

type DBConfig added in v1.1.0

type DBConfig struct {
	ConnectionString string `json:"connectionString"`
	Driver           string `json:"driver"`
}

type DiscoveryConfigV1 added in v1.0.1

type DiscoveryConfigV1 struct {
	// Time in seconds between remote discovery rounds
	DiscoveryInterval int
	//The maximum number of discovered nodes at a time
	Limit int
	MDNS  MDNSV1
}

type DiscoveryConfigV2 added in v1.0.1

type DiscoveryConfigV2 struct {
	// Time in seconds between remote discovery rounds
	DiscoveryInterval int `json:"discoveryInterval"`
	//The maximum number of discovered nodes at a time
	Limit       int  `json:"limit"`
	MDNSEnabled bool `json:"mDNSEnabled"`
	// Time in seconds between local discovery rounds
	MDNSInterval int `json:"mDNSInterval"`
}

type IdentityConfigV1 added in v1.0.1

type IdentityConfigV1 struct {
	PeerID  string
	PrivKey string `json:",omitempty"`
}

Identity tracks the configuration of the local node's identity.

type IdentityConfigV2 added in v1.0.1

type IdentityConfigV2 struct {
	PeerID  string `json:"peerId"`
	PrivKey string `json:"privateKey,omitempty" mapstructure:"privateKey"`
}

type Influx added in v1.3.0

type Influx struct {
	Enable   bool   `json:"enable"`
	URL      string `json:"url" validate:"nonzero"`
	Database string `json:"database" validate:"nonzero"`
	User     string `json:"user" validate:"nonzero"`
	Password string `json:"password"`
	Interval int    `json:"interval" validate:"min=1"`
}

type MDNSV1 added in v1.0.1

type MDNSV1 struct {
	Enabled bool
	// Time in seconds between local discovery rounds
	Interval int
}

type Manager added in v1.3.0

type Manager struct {
	AdminToken string `json:"adminToken"`
}

type MetricsConfig added in v1.3.0

type MetricsConfig struct {
	Enable         bool    `json:"enable"`
	SampleInterval int     `json:"sampleInterval" validate:"min=1"`
	Influx         *Influx `json:"influx"`
}

type MigrationV1ToV2 added in v1.0.1

type MigrationV1ToV2 struct {
	// contains filtered or unexported fields
}

func NewMigrationV1ToV2 added in v1.0.1

func NewMigrationV1ToV2() *MigrationV1ToV2

func (*MigrationV1ToV2) EndVersion added in v1.0.1

func (m *MigrationV1ToV2) EndVersion() int

func (*MigrationV1ToV2) Migration added in v1.0.1

func (m *MigrationV1ToV2) Migration(data []byte, version int) ([]byte, int, error)

func (*MigrationV1ToV2) StartVersion added in v1.0.1

func (m *MigrationV1ToV2) StartVersion() int

type MigrationV2ToV3 added in v1.1.0

type MigrationV2ToV3 struct {
	// contains filtered or unexported fields
}

func NewMigrationV2ToV3 added in v1.1.0

func NewMigrationV2ToV3() *MigrationV2ToV3

func (*MigrationV2ToV3) EndVersion added in v1.1.0

func (m *MigrationV2ToV3) EndVersion() int

func (*MigrationV2ToV3) Migration added in v1.1.0

func (m *MigrationV2ToV3) Migration(data []byte, version int) ([]byte, int, error)

func (*MigrationV2ToV3) StartVersion added in v1.1.0

func (m *MigrationV2ToV3) StartVersion() int

type MigrationV3ToV4 added in v1.2.3

type MigrationV3ToV4 struct {
	// contains filtered or unexported fields
}

func NewMigrationV3ToV4 added in v1.2.3

func NewMigrationV3ToV4() *MigrationV3ToV4

func (*MigrationV3ToV4) EndVersion added in v1.2.3

func (m *MigrationV3ToV4) EndVersion() int

func (*MigrationV3ToV4) Migration added in v1.2.3

func (m *MigrationV3ToV4) Migration(data []byte, version int) ([]byte, int, error)

func (*MigrationV3ToV4) StartVersion added in v1.2.3

func (m *MigrationV3ToV4) StartVersion() int

type MigrationV4ToV5 added in v1.3.0

type MigrationV4ToV5 struct {
	// contains filtered or unexported fields
}

func NewMigrationV4ToV5 added in v1.3.0

func NewMigrationV4ToV5() *MigrationV4ToV5

func (*MigrationV4ToV5) EndVersion added in v1.3.0

func (m *MigrationV4ToV5) EndVersion() int

func (*MigrationV4ToV5) Migration added in v1.3.0

func (m *MigrationV4ToV5) Migration(data []byte, version int) ([]byte, int, error)

func (*MigrationV4ToV5) StartVersion added in v1.3.0

func (m *MigrationV4ToV5) StartVersion() int

type P2PConfigV1 added in v1.0.1

type P2PConfigV1 struct {
	BootNodes []string `json:"BootNode"`
	Listen    string   `json:"Listen"`
	//Time in seconds between sync block interval
	SyncInterval int `json:"SyncInterval"`
}

type P2PConfigV2 added in v1.0.1

type P2PConfigV2 struct {
	BootNodes []string `json:"bootNode" mapstructure:"bootNode"`
	Listen    string   `json:"listen"`
	//Time in seconds between sync block interval
	SyncInterval int                `json:"syncInterval"`
	Discovery    *DiscoveryConfigV2 `json:"discovery"`
	ID           *IdentityConfigV2  `json:"identity" mapstructure:"identity"`
}

type PerformanceTestConfigV1 added in v1.0.1

type PerformanceTestConfigV1 struct {
	Enabled bool
}

type PoVConfig added in v1.2.3

type PoVConfig struct {
	PovEnabled   bool   `json:"povEnabled"`
	MinerEnabled bool   `json:"minerEnabled"`
	Coinbase     string `json:"coinbase" validate:"address"`
}

type RPCConfigV1 added in v1.0.1

type RPCConfigV1 struct {
	Enable bool `json:"enable"`
	//Listen string `json:"Listen"`
	HTTPEndpoint     string   `json:"hTTPEndpoint"`
	HTTPEnabled      bool     `json:"hTTPEnabled"`
	HTTPCors         []string `json:"hTTPCors"`
	HttpVirtualHosts []string `json:"httpVirtualHosts"`

	WSEnabled   bool   `json:"wSEnabled"`
	WSEndpoint  string `json:"wSEndpoint"`
	IPCEndpoint string `json:"iPCEndpoint"`

	IPCEnabled bool `json:"iPCEnabled"`
}

type RPCConfigV2 added in v1.0.1

type RPCConfigV2 struct {
	Enable bool `json:"rpcEnabled" mapstructure:"rpcEnabled"`
	//Listen string `json:"Listen"`
	HTTPEndpoint     string   `json:"httpEndpoint"`
	HTTPEnabled      bool     `json:"httpEnabled"`
	HTTPCors         []string `json:"httpCors"`
	HttpVirtualHosts []string `json:"httpVirtualHosts"`

	WSEnabled  bool   `json:"webSocketEnabled" mapstructure:"webSocketEnabled"`
	WSEndpoint string `json:"webSocketEndpoint" mapstructure:"webSocketEndpoint"`

	IPCEndpoint   string   `json:"ipcEndpoint"`
	IPCEnabled    bool     `json:"ipcEnabled"`
	PublicModules []string `json:"publicModules"`
}

Jump to

Keyboard shortcuts

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