Documentation ¶
Overview ¶
Provides the data structures and methods to work with the configuration data structure. This includes parsing, loading, and saving the configuration data structure. It uses the viper library to parse and manage the configuration data structure.
Index ¶
Constants ¶
const ( // DefaultMinSubmit default value for min_submit DefaultMinSubmit = 20 // DefaultMinConfirmation default value for min_confirmation DefaultMinConfirmation = 10 // DefaultMaxTxnQuery default value for max_txn_query DefaultMaxTxnQuery = 10 // DefaultConfirmationChainLength default value for confirmation_chain_length DefaultConfirmationChainLength = 3 // DefaultQuerySleepTime default value for query_sleep_time DefaultQuerySleepTime = 1 // DefaultSharderConsensous default consensous to take make SCRestAPI calls DefaultSharderConsensous = 3 )
Variables ¶
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
deprecated
added in
v1.2.89
func InitChainNetwork(n *Network)
Deprecated: Use client.Init() function. To normalize urls, use network.NormalizeURLs() method // InitChainNetwork set global chain network
func InitClientConfig ¶ added in v1.2.89
func InitClientConfig(c *Config)
InitClientConfig set global client config
func SetZboxAppConfigs ¶ added in v1.18.14
func SetZboxAppConfigs(zboxHost, zboxAppType string)
Types ¶
type Config ¶
type Config struct { // BlockWorker the url of 0dns's network api BlockWorker string `json:"block_worker,omitempty"` // MinSubmit mininal submit from blobber MinSubmit int `json:"min_submit,omitempty"` // MinConfirmation mininal confirmation from sharders MinConfirmation int `json:"min_confirmation,omitempty"` // CconfirmationChainLength minial confirmation chain length ConfirmationChainLength int `json:"confirmation_chain_length,omitempty"` // additional settings depending network latency // MaxTxnQuery maximum transcation query from sharders MaxTxnQuery int `json:"max_txn_query,omitempty"` // QuerySleepTime sleep time before transcation query QuerySleepTime int `json:"query_sleep_time,omitempty"` // SignatureScheme signature scheme SignatureScheme string `json:"signature_scheme,omitempty"` // ChainID which blockchain it is working ChainID string `json:"chain_id,omitempty"` VerifyOptimistic bool // Ethereum node: "https://ropsten.infura.io/v3/xxxxxxxxxxxxxxx" EthereumNode string `json:"ethereum_node,omitempty"` // ZboxHost 0box api host host: "https://0box.dev.0chain.net" ZboxHost string `json:"zbox_host"` // ZboxAppType app type name ZboxAppType string `json:"zbox_app_type"` // SharderConsensous is consensous for when quering for SCRestAPI calls SharderConsensous int `json:"sharder_consensous"` ZauthServer string `json:"zauth_server"` V *viper.Viper `json:"-"` }
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
GetClientConfig get global client config
func LoadConfigFile ¶
LoadConfigFile load and parse SDK Config from file
- file: config file path (full path)
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 LoadNetworkFile ¶
LoadNetworkFile load and parse Network from file
- file is the path of the file (full path)
func NewNetwork ¶ added in v1.17.13
func (*Network) NormalizeURLs ¶ added in v1.17.13
func (n *Network) NormalizeURLs()