config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultLogLevel is the default log level
	DefaultLogLevel = "info"
	// DefaultPrometheusPort is the default prometheus port
	DefaultPrometheusPort = uint32(9876)
	// DefaultRetainBlocks is the default number of blocks to retain
	DefaultRetainBlocks = uint32(512)
	// DefaultPruning is the default pruning strategy
	DefaultPruning = pruner.Archive

	// DefaultRole is the default node role
	DefaultRole = common.AuthorityRole
	// DefaultWasmInterpreter is the default wasm interpreter
	DefaultWasmInterpreter = wazero.Name

	// DefaultNetworkPort is the default network port
	DefaultNetworkPort = uint16(7001)
	// DefaultDiscoveryInterval is the default discovery interval
	DefaultDiscoveryInterval = 10 * time.Second
	// DefaultMinPeers is the default minimum number of peers
	DefaultMinPeers = 0
	// DefaultMaxPeers is the default maximum number of peers
	DefaultMaxPeers = 50

	// DefaultRPCPort is the default RPC port
	DefaultRPCPort = uint32(8545)
	// DefaultRPCHost is the default RPC host
	DefaultRPCHost = "localhost"
	// DefaultWSPort is the default WS port
	DefaultWSPort = uint32(8546)

	// DefaultPprofListenAddress is the default pprof listen address
	DefaultPprofListenAddress = "localhost:6060"

	// DefaultSystemName is the default system name
	DefaultSystemName = "Gossamer"
	// DefaultSystemVersion is the default system version
	DefaultSystemVersion = "0.0.0"
)
View Source
const (
	VersionMajor = 0
	VersionMinor = 9
	VersionPatch = 0
	VersionMeta  = "unstable"
)

Sets the numeric Gossamer version here

View Source
const (
	// DefaultDirPerm is the default directory permission for gossamer files
	DefaultDirPerm = 0o700
)

Variables

View Source
var DefaultRPCModules = []string{
	"system",
	"author",
	"chain",
	"state",
	"rpc",
	"grandpa",
	"offchain",
	"childstate",
	"syncstate",
	"payment",
}

DefaultRPCModules the default RPC modules

View Source
var GitCommit = func() string {
	if info, ok := debug.ReadBuildInfo(); ok {
		for _, setting := range info.Settings {
			if setting.Key == "vcs.revision" {
				return setting.Value
			}
		}
	}
	return ""
}()

GitCommit attempts to get a Git commit hash; empty string otherwise

View Source
var Version = func() string {
	if VersionMeta != "stable" {
		return GetFullVersion()
	} else {
		return GetStableVersion()
	}
}()

Version holds a text representation of the Gossamer version

Functions

func EnsureRoot

func EnsureRoot(basePath string) error

EnsureRoot creates the root, config, and data directories if they don't exist, and returns error if it fails.

func GetChainSpec

func GetChainSpec(basePath string) string

GetChainSpec returns the path to the chain-spec file.

func GetFullVersion added in v0.9.0

func GetFullVersion() string

GetFullVersion gets a verbose, long version string, e.g., 0.9.0-unstable-e41617ba

func GetStableVersion added in v0.9.0

func GetStableVersion() string

GetStableVersion gets a short, stable version string, e.g., 0.9.0

func WriteConfigFile

func WriteConfigFile(basePath string, config *Config) error

WriteConfigFile writes the config to the base path.

Types

type AccountConfig

type AccountConfig struct {
	Key    string `mapstructure:"key,omitempty"`
	Unlock string `mapstructure:"unlock,omitempty"`
}

AccountConfig is to marshal/unmarshal account config vars

func (*AccountConfig) ValidateBasic

func (a *AccountConfig) ValidateBasic() error

ValidateBasic does the basic validation on AccountConfig

type BaseConfig

type BaseConfig struct {
	Name               string                      `mapstructure:"name,omitempty"`
	ID                 string                      `mapstructure:"id,omitempty"`
	BasePath           string                      `mapstructure:"base-path,omitempty"`
	ChainSpec          string                      `mapstructure:"chain-spec,omitempty"`
	LogLevel           string                      `mapstructure:"log-level,omitempty"`
	PrometheusPort     uint32                      `mapstructure:"prometheus-port,omitempty"`
	RetainBlocks       uint32                      `mapstructure:"retain-blocks,omitempty"`
	Pruning            pruner.Mode                 `mapstructure:"pruning,omitempty"`
	PrometheusExternal bool                        `mapstructure:"prometheus-external,omitempty"`
	NoTelemetry        bool                        `mapstructure:"no-telemetry"`
	TelemetryURLs      []genesis.TelemetryEndpoint `mapstructure:"telemetry-urls,omitempty"`
}

BaseConfig is to marshal/unmarshal toml global config vars

func (*BaseConfig) ValidateBasic

func (b *BaseConfig) ValidateBasic() error

ValidateBasic does the basic validation on BaseConfig

type Chain

type Chain string

Chain is a string representing a chain

const (
	// PolkadotChain is the Polkadot chain
	PolkadotChain Chain = "polkadot"
	// KusamaChain is the Kusama chain
	KusamaChain Chain = "kusama"
	// WestendChain is the Westend chain
	WestendChain Chain = "westend"
	// WestendDevChain is the Westend dev chain
	WestendDevChain Chain = "westend-dev"
	// WestendLocalChain is the Westend local chain
	WestendLocalChain Chain = "westend-local"
	// PaseoChain is the Paseo chain
	PaseoChain Chain = "paseo"
)

func (Chain) String

func (c Chain) String() string

String returns the string representation of the chain

type Config

type Config struct {
	BaseConfig `mapstructure:",squash"`
	Log        *LogConfig     `mapstructure:"log"`
	Account    *AccountConfig `mapstructure:"account"`
	Core       *CoreConfig    `mapstructure:"core"`
	Network    *NetworkConfig `mapstructure:"network"`
	State      *StateConfig   `mapstructure:"state"`
	RPC        *RPCConfig     `mapstructure:"rpc"`
	Pprof      *PprofConfig   `mapstructure:"pprof"`

	// System holds the system information
	// Do not export this field, as it is not part of the config file
	// and should be set in the source code
	System *SystemConfig
}

Config defines the configuration for the gossamer node

func Copy

func Copy(c *Config) Config

Copy creates a copy of the config.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func DefaultConfigFromSpec

func DefaultConfigFromSpec(nodeSpec *genesis.Genesis) *Config

DefaultConfigFromSpec returns the default configuration.

func (*Config) ValidateBasic

func (cfg *Config) ValidateBasic() error

ValidateBasic performs basic validation on the config

type CoreConfig

type CoreConfig struct {
	Role             common.NetworkRole `mapstructure:"role,omitempty"`
	BabeAuthority    bool               `mapstructure:"babe-authority"`
	GrandpaAuthority bool               `mapstructure:"grandpa-authority"`
	WasmInterpreter  string             `mapstructure:"wasm-interpreter,omitempty"`
	GrandpaInterval  time.Duration      `mapstructure:"grandpa-interval,omitempty"`
}

CoreConfig is to marshal/unmarshal toml core config vars

func (*CoreConfig) ValidateBasic

func (c *CoreConfig) ValidateBasic() error

ValidateBasic does the basic validation on CoreConfig

type LogConfig

type LogConfig struct {
	Core    string `mapstructure:"core,omitempty"`
	Digest  string `mapstructure:"digest,omitempty"`
	Sync    string `mapstructure:"sync,omitempty"`
	Network string `mapstructure:"network,omitempty"`
	RPC     string `mapstructure:"rpc,omitempty"`
	State   string `mapstructure:"state,omitempty"`
	Runtime string `mapstructure:"runtime,omitempty"`
	Babe    string `mapstructure:"babe,omitempty"`
	Grandpa string `mapstructure:"grandpa,omitempty"`
	Wasmer  string `mapstructure:"wasmer,omitempty"`
}

LogConfig represents the log levels for individual packages

func (*LogConfig) ValidateBasic

func (l *LogConfig) ValidateBasic() error

ValidateBasic does the basic validation on LogConfig

type NetworkConfig

type NetworkConfig struct {
	Port              uint16        `mapstructure:"port"`
	Bootnodes         []string      `mapstructure:"bootnodes"`
	ProtocolID        string        `mapstructure:"protocol"`
	NoBootstrap       bool          `mapstructure:"no-bootstrap"`
	NoMDNS            bool          `mapstructure:"no-mdns"`
	MinPeers          int           `mapstructure:"min-peers"`
	MaxPeers          int           `mapstructure:"max-peers"`
	PersistentPeers   []string      `mapstructure:"persistent-peers"`
	DiscoveryInterval time.Duration `mapstructure:"discovery-interval"`
	PublicIP          string        `mapstructure:"public-ip"`
	PublicDNS         string        `mapstructure:"public-dns"`
	NodeKey           string        `mapstructure:"node-key"`
	ListenAddress     string        `mapstructure:"listen-addr"`
}

NetworkConfig is to marshal/unmarshal toml network config vars

func (*NetworkConfig) ValidateBasic

func (n *NetworkConfig) ValidateBasic() error

ValidateBasic does the basic validation on NetworkConfig

type NetworkRole

type NetworkRole string

NetworkRole is a string representing a network role

const (
	// NoNetworkRole is no network role
	NoNetworkRole NetworkRole = "none"

	// FullNode is a full node
	FullNode NetworkRole = "full"

	// LightNode is a light node
	LightNode NetworkRole = "light"

	// AuthorityNode is an authority node
	AuthorityNode NetworkRole = "authority"
)

func (NetworkRole) String

func (n NetworkRole) String() string

String returns the string representation of the network role

type PprofConfig

type PprofConfig struct {
	Enabled          bool   `mapstructure:"enabled,omitempty"`
	ListeningAddress string `mapstructure:"listening-address,omitempty"`
	BlockProfileRate int    `mapstructure:"block-profile-rate,omitempty"`
	MutexProfileRate int    `mapstructure:"mutex-profile-rate,omitempty"`
}

PprofConfig contains the configuration for Pprof.

func (*PprofConfig) ValidateBasic

func (p *PprofConfig) ValidateBasic() error

ValidateBasic does the basic validation on StateConfig

type RPCConfig

type RPCConfig struct {
	RPCExternal       bool     `mapstructure:"rpc-external,omitempty"`
	UnsafeRPC         bool     `mapstructure:"unsafe-rpc,omitempty"`
	UnsafeRPCExternal bool     `mapstructure:"unsafe-rpc-external,omitempty"`
	Port              uint32   `mapstructure:"port,omitempty"`
	Host              string   `mapstructure:"host,omitempty"`
	Modules           []string `mapstructure:"modules,omitempty"`
	WSPort            uint32   `mapstructure:"ws-port,omitempty"`
	WSExternal        bool     `mapstructure:"ws-external,omitempty"`
	UnsafeWSExternal  bool     `mapstructure:"unsafe-ws-external,omitempty"`
}

RPCConfig is to marshal/unmarshal toml RPC config vars

func (*RPCConfig) IsRPCEnabled

func (r *RPCConfig) IsRPCEnabled() bool

IsRPCEnabled returns true if RPC is enabled.

func (*RPCConfig) IsWSEnabled

func (r *RPCConfig) IsWSEnabled() bool

IsWSEnabled returns true if WS is enabled.

func (*RPCConfig) ValidateBasic

func (r *RPCConfig) ValidateBasic() error

ValidateBasic does the basic validation on RPCConfig

type StateConfig

type StateConfig struct {
	Rewind uint `mapstructure:"rewind,omitempty"`
}

StateConfig contains the configuration for the state.

func (*StateConfig) ValidateBasic

func (s *StateConfig) ValidateBasic() error

ValidateBasic does the basic validation on StateConfig

type SystemConfig

type SystemConfig struct {
	SystemName    string
	SystemVersion string
}

SystemConfig represents the system configuration

Jump to

Keyboard shortcuts

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