config

package
v0.0.0-...-f42d900 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DenomUSD = "USD"

	ProviderKraken   = "kraken"
	ProviderBinance  = "binance"
	ProviderMexc     = "mexc"
	ProviderHuobi    = "huobi"
	ProviderOkx      = "okx"
	ProviderGate     = "gate"
	ProviderCoinbase = "coinbase"
	ProviderMock     = "mock"
)

Variables

View Source
var (

	// ErrEmptyConfigPath defines a sentinel error for an empty config path.
	ErrEmptyConfigPath = errors.New("empty configuration file path")

	// SupportedProviders defines a lookup table of all the supported currency API
	// providers.
	SupportedProviders = map[string]struct{}{
		ProviderKraken:   {},
		ProviderBinance:  {},
		ProviderMexc:     {},
		ProviderOkx:      {},
		ProviderHuobi:    {},
		ProviderGate:     {},
		ProviderCoinbase: {},
		ProviderMock:     {},
	}

	// SupportedQuotes defines a lookup table for which assets we support
	// using as quotes.
	SupportedQuotes = map[string]struct{}{
		DenomUSD:  {},
		"AXLUSDC": {},
		"USDC":    {},
		"USDT":    {},
		"DAI":     {},
		"BTC":     {},
		"ETH":     {},
		"ATOM":    {},
	}
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ChainID    string `toml:"chain_id" validate:"required"`
	Address    string `toml:"address" validate:"required"`
	Validator  string `toml:"validator" validate:"required"`
	FeeGranter string `toml:"fee_granter"`
	Prefix     string `toml:"prefix" validate:"required"`
}

Account defines account related configuration that is related to the network and transaction signing functionality.

type Config

type Config struct {
	Server            Server             `toml:"server"`
	CurrencyPairs     []CurrencyPair     `toml:"currency_pairs" validate:"required,gt=0,dive,required"`
	Deviations        []Deviation        `toml:"deviation_thresholds"`
	Account           Account            `toml:"account" validate:"required,gt=0,dive,required"`
	Keyring           Keyring            `toml:"keyring" validate:"required,gt=0,dive,required"`
	RPC               RPC                `toml:"rpc" validate:"required,gt=0,dive,required"`
	Telemetry         Telemetry          `toml:"telemetry"`
	GasAdjustment     float64            `toml:"gas_adjustment" validate:"required"`
	GasPrices         string             `toml:"gas_prices" validate:"required"`
	ProviderTimeout   string             `toml:"provider_timeout"`
	ProviderEndpoints []ProviderEndpoint `toml:"provider_endpoints" validate:"dive"`
	EnableServer      bool               `toml:"enable_server"`
	EnableVoter       bool               `toml:"enable_voter"`
	Healthchecks      []Healthchecks     `toml:"healthchecks" validate:"dive"`
}

Config defines all necessary price-feeder configuration parameters.

func ParseConfig

func ParseConfig(configPath string) (Config, error)

ParseConfig attempts to read and parse configuration from the given file path. An error is returned if reading or parsing the config fails.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the Config object is invalid.

type CurrencyPair

type CurrencyPair struct {
	Base       string   `toml:"base" validate:"required"`
	ChainDenom string   `toml:"chain_denom" validate:"required"`
	Quote      string   `toml:"quote" validate:"required"`
	Providers  []string `toml:"providers" validate:"required,gt=0,dive,required"`
}

CurrencyPair defines a price quote of the exchange rate for two different currencies and the supported providers for getting the exchange rate.

type Deviation

type Deviation struct {
	Base      string `toml:"base" validate:"required"`
	Threshold string `toml:"threshold" validate:"required"`
}

Deviation defines a maximum amount of standard deviations that a given asset can be from the median without being filtered out before voting.

type Healthchecks

type Healthchecks struct {
	URL     string `toml:"url" validate:"required"`
	Timeout string `toml:"timeout" validate:"required"`
}

type Keyring

type Keyring struct {
	Backend string `toml:"backend" validate:"required"`
	Dir     string `toml:"dir" validate:"required"`
}

Keyring defines the required keyring configuration.

type ProviderEndpoint

type ProviderEndpoint struct {
	// Name of the provider, ex. "binance"
	Name string `toml:"name"`

	// Rest endpoint for the provider, ex. "https://api1.binance.com"
	Rest string `toml:"rest"`

	// Websocket endpoint for the provider, ex. "stream.binance.com:9443"
	Websocket string `toml:"websocket"`
}

ProviderEndpoint defines an override setting in our config for the hardcoded rest and websocket api endpoints.

type RPC

type RPC struct {
	TMRPCEndpoint string `toml:"tmrpc_endpoint" validate:"required"`
	GRPCEndpoint  string `toml:"grpc_endpoint" validate:"required"`
	RPCTimeout    string `toml:"rpc_timeout" validate:"required"`
}

RPC defines RPC configuration of both the gRPC and Tendermint nodes.

type Server

type Server struct {
	ListenAddr     string   `toml:"listen_addr"`
	WriteTimeout   string   `toml:"write_timeout"`
	ReadTimeout    string   `toml:"read_timeout"`
	VerboseCORS    bool     `toml:"verbose_cors"`
	AllowedOrigins []string `toml:"allowed_origins"`
}

Server defines the API server configuration.

type Telemetry

type Telemetry struct {
	// Prefixed with keys to separate services
	ServiceName string `toml:"service_name" mapstructure:"service-name"`

	// Enabled enables the application telemetry functionality. When enabled,
	// an in-memory sink is also enabled by default. Operators may also enabled
	// other sinks such as Prometheus.
	Enabled bool `toml:"enabled" mapstructure:"enabled"`

	// Enable prefixing gauge values with hostname
	EnableHostname bool `toml:"enable_hostname" mapstructure:"enable-hostname"`

	// Enable adding hostname to labels
	EnableHostnameLabel bool `toml:"enable_hostname_label" mapstructure:"enable-hostname-label"`

	// Enable adding service to labels
	EnableServiceLabel bool `toml:"enable_service_label" mapstructure:"enable-service-label"`

	// GlobalLabels defines a global set of name/value label tuples applied to all
	// metrics emitted using the wrapper functions defined in telemetry package.
	//
	// Example:
	// [["chain_id", "cosmoshub-1"]]
	GlobalLabels [][]string `toml:"global_labels" mapstructure:"global-labels"`

	// PrometheusRetentionTime, when positive, enables a Prometheus metrics sink.
	// It defines the retention duration in seconds.
	PrometheusRetentionTime int64 `toml:"prometheus_retention" mapstructure:"prometheus-retention-time"`
}

Telemetry defines the configuration options for application telemetry.

Jump to

Keyboard shortcuts

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