conf

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 8 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// DefaultMinSubmit default value for min_submit
	DefaultMinSubmit = 50
	// DefaultMinConfirmation default value for min_confirmation
	DefaultMinConfirmation = 50
	// DefaultMaxTxnQuery default value for max_txn_query
	DefaultMaxTxnQuery = 5
	// DefaultConfirmationChainLength default value for confirmation_chain_length
	DefaultConfirmationChainLength = 3
	// DefaultQuerySleepTime default value for query_sleep_time
	DefaultQuerySleepTime = 5
)

Variables

View Source
var (
	//ErrNilConfig config is nil
	ErrNilConfig = errors.New("[conf]config is nil")

	// ErrMssingConfig config file is missing
	ErrMssingConfig = errors.New("[conf]missing config file")
	// ErrInvalidValue invalid value in config
	ErrInvalidValue = errors.New("[conf]invalid value")
	// ErrBadParsing fail to parse config via spf13/viper
	ErrBadParsing = errors.New("[conf]bad parsing")

	// ErrConfigNotInitialized config is not initialized
	ErrConfigNotInitialized = errors.New("[conf]conf.cfg is not initialized. please initialize it by conf.InitClientConfig")
)

Functions

func InitChainNetwork added in v1.2.89

func InitChainNetwork(n *Network)

InitChainNetwork set global chain network

func InitClientConfig added in v1.2.89

func InitClientConfig(c *Config)

InitClientConfig set global client config

Types

type Config

type Config struct {
	// BlockWorker the url of 0dns's network api
	BlockWorker string
	// PreferredBlobbers preferred blobbers on new allocation
	PreferredBlobbers []string

	// MinSubmit mininal submit from blobber
	MinSubmit int
	// MinConfirmation mininal confirmation from sharders
	MinConfirmation int
	// CconfirmationChainLength minial confirmation chain length
	ConfirmationChainLength int

	// additional settings depending network latency
	// MaxTxnQuery maximum transcation query from sharders
	MaxTxnQuery int
	// QuerySleepTime sleep time before transcation query
	QuerySleepTime int

	// SignatureScheme signature scheme
	SignatureScheme string
	// ChainID which blockchain it is working
	ChainID string

	// Ethereum node: "https://ropsten.infura.io/v3/xxxxxxxxxxxxxxx"
	EthereumNode string
}

Config settings from ~/.zcn/config.yaml block_worker: http://198.18.0.98:9091 signature_scheme: bls0chain min_submit: 50 min_confirmation: 50 confirmation_chain_length: 3 max_txn_query: 5 query_sleep_time: 5 # # OPTIONAL - Uncomment to use/ Add more if you want # preferred_blobbers: # - http://one.devnet-0chain.net:31051 # - http://one.devnet-0chain.net:31052 # - http://one.devnet-0chain.net:31053

func GetClientConfig added in v1.2.89

func GetClientConfig() (*Config, error)

GetClientConfig get global client config

func LoadConfig

func LoadConfig(v Reader) (Config, error)

LoadConfig load and parse config

func LoadConfigFile

func LoadConfigFile(file string) (Config, error)

LoadConfigFile load and parse Config from file

type JSONReader added in v1.2.89

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

JSONReader read config from json

func (*JSONReader) GetInt added in v1.2.89

func (r *JSONReader) GetInt(key string) int

GetInt read int from key

func (*JSONReader) GetString added in v1.2.89

func (r *JSONReader) GetString(key string) string

GetString read string from key

func (*JSONReader) GetStringSlice added in v1.2.89

func (r *JSONReader) GetStringSlice(key string) []string

GetStringSlice get string slice from key

type Network

type Network struct {
	// Sharders sharder list of blockchain
	Sharders []string
	// Miners miner list of blockchain
	Miners []string
}

Network settings from ~/.zcn/network.yaml

func LoadNetwork

func LoadNetwork(v Reader) Network

LoadNetwork load and parse network

func LoadNetworkFile

func LoadNetworkFile(file string) (Network, error)

LoadNetworkFile load and parse Network from file

func (*Network) IsValid

func (n *Network) IsValid() bool

IsValid check network if it has miners and sharders

type Reader

type Reader interface {
	GetString(key string) string
	GetInt(key string) int
	GetStringSlice(key string) []string
}

Reader a config reader

func NewReaderFromJSON added in v1.2.89

func NewReaderFromJSON(data string) (Reader, error)

NewReaderFromJSON create a JSONReader from json string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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