Documentation
¶
Overview ¶
Package config provides utility functions for parsing and extracting specific information from a server configuration. It includes functions for parsing the genesis configuration, network addresses, secrets configuration, and node type. The package handles various scenarios, such as handling missing or empty fields, providing default values, and returning appropriate errors.
Index ¶
- func ParseDNSAddress(cfg *Config, p2pPort int) (multiaddr.Multiaddr, error)
- func ParseGenesisConfig(cfg *Config) (*chain.Chain, error)
- func ParseGrpcAddress(cfg *Config) (*net.TCPAddr, error)
- func ParseJsonRpcAddress(cfg *Config) (*net.TCPAddr, error)
- func ParseLibp2pAddress(cfg *Config) (*net.TCPAddr, error)
- func ParseNatAddress(cfg *Config) (net.IP, error)
- func ParseNodeType(cfg *Config) (avail.MechanismType, error)
- func ParsePrometheusAddress(cfg *Config) (*net.TCPAddr, error)
- func ParseSecretsConfig(cfg *Config) (*secrets.SecretsManagerConfig, error)
- type Config
- type CustomServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDNSAddress ¶
ParseDNSAddress parses the DNS address from the configuration file. If the DNS address is not defined or empty, it returns nil. Otherwise, it constructs a multiaddr.Multiaddr instance using the common.MultiAddrFromDNS function.
func ParseGenesisConfig ¶
ParseGenesisConfig parses the genesis configuration from the provided Config and returns a *chain.Chain instance. It imports the chain from the specified genesis path and handles any parsing errors.
func ParseGrpcAddress ¶
ParseGrpcAddress parses the gRPC address from the configuration file. It resolves the address using the helper.ResolveAddr function.
func ParseJsonRpcAddress ¶
ParseJsonRpcAddress parses the JSON-RPC address from the configuration file. It resolves the address using the helper.ResolveAddr function.
func ParseLibp2pAddress ¶
ParseLibp2pAddress parses the libp2p address from the configuration file. It resolves the address using the helper.ResolveAddr function.
func ParseNatAddress ¶
ParseNatAddress parses the NAT address from the configuration file. If the NAT address is not defined or empty, it returns nil. Otherwise, it parses the address as a net.IP instance.
func ParseNodeType ¶
func ParseNodeType(cfg *Config) (avail.MechanismType, error)
ParseNodeType parses the node type from the configuration file and returns an avail.MechanismType value. If the node type is not defined or empty, it returns avail.Validator. Otherwise, it parses the node type using the avail.ParseType function.
func ParsePrometheusAddress ¶
ParsePrometheusAddress parses the Prometheus address from the configuration file. If the Prometheus address is not defined or empty, it returns nil. Otherwise, it resolves the address using the helper.ResolveAddr function.
func ParseSecretsConfig ¶
func ParseSecretsConfig(cfg *Config) (*secrets.SecretsManagerConfig, error)
ParseSecretsConfig parses the secrets configuration from the provided Config and returns a *secrets.SecretsManagerConfig instance. If the secrets configuration path is not defined or empty, it returns nil. Otherwise, it reads the configuration using the secrets.ReadConfig function.
Types ¶
type Config ¶
type Config struct {
GenesisPath string `json:"chain_config" yaml:"chain_config"`
SecretsConfigPath string `json:"secrets_config" yaml:"secrets_config"`
DataDir string `json:"data_dir" yaml:"data_dir"`
BlockGasTarget string `json:"block_gas_target" yaml:"block_gas_target"`
GRPCAddr string `json:"grpc_addr" yaml:"grpc_addr"`
JSONRPCAddr string `json:"jsonrpc_addr" yaml:"jsonrpc_addr"`
Telemetry *config.Telemetry `json:"telemetry" yaml:"telemetry"`
Network *config.Network `json:"network" yaml:"network"`
ShouldSeal bool `json:"seal" yaml:"seal"`
TxPool *config.TxPool `json:"tx_pool" yaml:"tx_pool"`
LogLevel string `json:"log_level" yaml:"log_level"`
RestoreFile string `json:"restore_file" yaml:"restore_file"`
BlockTime uint64 `json:"block_time_s" yaml:"block_time_s"`
Headers *config.Headers `json:"headers" yaml:"headers"`
LogFilePath string `json:"log_to" yaml:"log_to"`
JSONRPCBatchRequestLimit uint64 `json:"json_rpc_batch_request_limit" yaml:"json_rpc_batch_request_limit"`
JSONRPCBlockRangeLimit uint64 `json:"json_rpc_block_range_limit" yaml:"json_rpc_block_range_limit"`
JSONLogFormat bool `json:"json_log_format" yaml:"json_log_format"`
Relayer bool `json:"relayer" yaml:"relayer"`
NumBlockConfirmations uint64 `json:"num_block_confirmations" yaml:"num_block_confirmations"`
NodeType string `json:"node_type" yaml:"node_type"`
}
Config defines the server configuration params.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default server configuration.
func ReadConfigFile ¶
ReadConfigFile reads the config file from the specified path, builds a Config object, and returns it.
Supported file types: .json, .hcl, .yaml, .yml
type CustomServerConfig ¶
CustomServerConfig is a custom configuration for the server.
func NewServerConfig ¶
func NewServerConfig(path string) (*CustomServerConfig, error)
NewServerConfig creates a new CustomServerConfig based on the configuration file at the specified path.