config

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config is the reporter's akash-style configuration: a TOML file at <home>/config/reporter.toml, AKT_REPORTER_* environment variables, flags and validation.

Index

Constants

View Source
const (
	// MainnetChainID is the Akash mainnet chain ID that the mainnet network guard requires.
	MainnetChainID = "akashnet-2"
	// MainnetGenesis is the Solana mainnet genesis hash that the mainnet network guard requires.
	MainnetGenesis = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
	// DevProgramID is the development program ID that the mainnet network guard refuses.
	DevProgramID = "FfFAPUKqjf68ggj1HvpyzMHFDRnT2cFAdZYYQb7mK9i5"

	// EnvPrefix is the prefix of every environment variable the reporter reads.
	EnvPrefix = "AKT_REPORTER"
	// FlagHome is the name of the home directory flag. It is not a configuration key.
	FlagHome = "home"
)

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(fs *pflag.FlagSet)

AddFlags registers one flag per key, named by the dotted key, and the home flag unless it already exists.

func FilePath

func FilePath(home string) string

FilePath returns the configuration file of a home directory.

func Known

func Known() []string

Known returns every configuration key in declaration order.

func Render

func Render(c Config) ([]byte, error)

Render returns the reporter.toml text of c, with one comment per key.

func ResolveHome

func ResolveHome(flags *pflag.FlagSet, environ []string) (string, error)

ResolveHome returns the home directory: --home, then AKT_REPORTER_HOME, then $HOME/.akt-reporter.

Types

type Config

type Config struct {
	Legacy *Legacy `mapstructure:"-"`

	Network        string        `mapstructure:"network"`
	Broadcast      bool          `mapstructure:"broadcast"`
	Reporter       string        `mapstructure:"reporter"`
	ChainID        string        `mapstructure:"chain-id"`
	Node           string        `mapstructure:"node"`
	GRPCAddr       string        `mapstructure:"grpc-addr"`
	GRPCInsecure   bool          `mapstructure:"grpc-insecure"`
	MaxAge         time.Duration `mapstructure:"max-age"`
	RequestTimeout time.Duration `mapstructure:"request-timeout"`
	From           string        `mapstructure:"from"`
	KeyringBackend string        `mapstructure:"keyring-backend"`
	KeyringDir     string        `mapstructure:"keyring-dir"`
	Gas            string        `mapstructure:"gas"`
	GasAdjustment  float64       `mapstructure:"gas-adjustment"`
	GasPrices      string        `mapstructure:"gas-prices"`
	Fees           string        `mapstructure:"fees"`

	Solana  Solana  `mapstructure:"solana"`
	Scan    Scan    `mapstructure:"scan"`
	Tx      Tx      `mapstructure:"tx"`
	Signer  Signer  `mapstructure:"signer"`
	Metrics Metrics `mapstructure:"metrics"`
}

Config mirrors the keys of spec section 8.3. The mapstructure tags are the key names, so a key is the dotted path of its tags.

func Default

func Default() Config

Default returns the defaults of spec section 8.3. Required keys are empty. KeyringDir is empty here and Load fills it with the home directory.

func Load

func Load(flags *pflag.FlagSet, environ []string) (Config, []string, error)

Load reads the configuration with the precedence flag, environment, file, default. flags must come from AddFlags and be parsed. It does not validate values; see Resolve. Unknown keys in the file are errors. Unknown AKT_REPORTER_* variables are returned as warnings.

func LoadLegacy

func LoadLegacy(path, network string, broadcast bool) (Config, error)

LoadLegacy reads the old packaged JSON without inspecting keys or contacting services. Resolve applies the same identity, fee, gas and broadcast safety rules as canonical input.

func LoadWithoutFile

func LoadWithoutFile(flags *pflag.FlagSet, environ []string) (Config, []string, error)

LoadWithoutFile is Load without the configuration file: the precedence is flag, environment, default. init renders it, so that an existing file never leaks into its replacement.

type ExternalSigner

type ExternalSigner struct {
	Options   signer.CommandOptions
	PublicKey cryptotypes.PubKey
}

ExternalSigner holds the legacy JSON command settings and an optional validated public key. A missing key is looked up only during broadcast startup.

type Legacy

type Legacy struct {
	KeyFile        string
	ExternalSigner *ExternalSigner
}

Legacy selects the packaged JSON input and single-Comet query transport. It is set only by LoadLegacy, never by TOML, environment or canonical flags.

type Metrics

type Metrics struct {
	Listen string `mapstructure:"listen"`
}

Metrics holds the metrics.* keys.

type Remote

type Remote struct {
	Address    string        `mapstructure:"address"`
	KeyID      string        `mapstructure:"key-id"`
	CAFile     string        `mapstructure:"ca-file"`
	ServerName string        `mapstructure:"server-name"`
	CertFile   string        `mapstructure:"cert-file"`
	KeyFile    string        `mapstructure:"key-file"`
	Timeout    time.Duration `mapstructure:"timeout"`
}

Remote holds the signer.remote.* keys.

type Resolved

type Resolved struct {
	Config

	ProgramID, Mint solana.PublicKey
	// LightClientPin is nil when solana.light-client-program is empty, which follows the bridge account.
	LightClientPin *solana.PublicKey
	Reporter       sdk.AccAddress
	// SlotLead is solana.max-slot-lead or, when that is 0, (max-age + 60 s) rounded up to whole seconds, x 5.
	SlotLead uint64
	// GasPerMessage is 0 for gas = auto.
	GasPerMessage uint64
	// GasPrices is empty when only fees is set.
	GasPrices sdk.DecCoins
	// Fees is empty when fees is unset or explicitly zero in legacy JSON.
	Fees   sdk.Coins
	MaxFee sdk.Coin
}

Resolved is a validated Config with its derived values parsed.

func Resolve

func Resolve(c Config) (Resolved, error)

Resolve checks every rule of spec sections 8.3 and 8.4 and parses the derived values. The error joins every broken rule, each starting with its key. The Resolved is zero when there is an error.

type Scan

type Scan struct {
	Interval          time.Duration `mapstructure:"interval"`
	AuditPerScan      int           `mapstructure:"audit-per-scan"`
	PageSize          int           `mapstructure:"page-size"`
	Workers           int           `mapstructure:"workers"`
	AkashConcurrency  int           `mapstructure:"akash-concurrency"`
	SolanaConcurrency int           `mapstructure:"solana-concurrency"`
	BlockConcurrency  int           `mapstructure:"block-concurrency"`
}

Scan holds the scan.* keys.

type Signer

type Signer struct {
	Remote Remote `mapstructure:"remote"`
}

Signer holds the signer.* keys.

type Solana

type Solana struct {
	RPC                string `mapstructure:"rpc"`
	GenesisHash        string `mapstructure:"genesis-hash"`
	ProgramID          string `mapstructure:"program-id"`
	Mint               string `mapstructure:"mint"`
	LightClientProgram string `mapstructure:"light-client-program"`
	MaxSlotLead        uint64 `mapstructure:"max-slot-lead"`
}

Solana holds the solana.* keys.

type Tx

type Tx struct {
	MaxGas      uint64 `mapstructure:"max-gas"`
	MaxFee      string `mapstructure:"max-fee"`
	MaxMsgs     int    `mapstructure:"max-msgs"`
	MaxInFlight int    `mapstructure:"max-in-flight"`
}

Tx holds the tx.* keys.

Jump to

Keyboard shortcuts

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