nodecfg

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Overview

Package nodecfg provides functions to assist in the generation of new kwild node configurations. This is primarily intended for the kwil-admin commands and tests that required dynamic node configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNodeConfig

func GenerateNodeConfig(genCfg *NodeGenerateConfig) error

GenerateNodeConfig is used to generate configuration required for running a kwil node. This includes the files: private_key, config.toml, genesis.json.

  • The private key is generated if it does not exist.
  • The genesis file is generated if it does not exist. A new genesis file will include the node as a validator; existing genesis is not updated.
  • The config.toml file is generated if it does not exist.

func GenerateNodeFiles

func GenerateNodeFiles(outputDir string, originalCfg *config.KwildConfig, silence bool) (publicKey []byte, err error)

GenerateNodeFiles will generate all generic node files that are not dependent on the network configuration (e.g. genesis.json). It can optionally be given a config file to merge with the default config.

func GenerateTestnetConfig

func GenerateTestnetConfig(genCfg *TestnetGenerateConfig, opts *ConfigOpts) error

GenerateTestnetConfig is like GenerateNodeConfig but it generates multiple configs for a network of nodes on a LAN. See also TestnetGenerateConfig.

func WriteConfigFile

func WriteConfigFile(configFilePath string, cfg *config.KwildConfig) error

WriteConfigFile writes the config to a file.

Types

type ConfigOpts

type ConfigOpts struct {
	// UniquePorts is a flag to generate unique listening addresses
	// (gRPC, HTTP, Admin, P2P, RPC) for each node.
	// This is useful for testing multiple nodes on the same machine.
	// If it is used for generating a single config, it has no effect.
	UniquePorts bool

	// NoGenesis is a flag to not generate a genesis file.
	// This is useful if you are generating a node config for
	// a network that already has a genesis file.
	// If used with creating a testnet, it will result in an error.
	NoGenesis bool

	// DnsHost is a flag to use DNS hostname as host in the config
	// instead of ip. It will be used together with DnsNamePrefix to generate
	// hostnames.
	// This is useful for testing nodes inside docker containers.
	DnsHost bool
}

ConfigOpts is a struct to alter the generation of the node config.

type NodeGenerateConfig

type NodeGenerateConfig struct {
	ChainID       string
	BlockInterval time.Duration
	// InitialHeight int64 // ?
	OutputDir       string
	JoinExpiry      int64
	WithoutGasCosts bool
	WithoutNonces   bool
	Allocs          map[string]*big.Int
	VoteExpiry      int64
	Extensions      map[string]map[string]string
}

type TestnetGenerateConfig

type TestnetGenerateConfig struct {
	ChainID       string
	BlockInterval time.Duration
	// InitialHeight           int64
	NValidators             int
	NNonValidators          int
	ConfigFile              string
	OutputDir               string
	NodeDirPrefix           string
	PopulatePersistentPeers bool
	HostnamePrefix          string
	HostnameSuffix          string
	StartingIPAddress       string
	DnsNamePrefix           string
	Hostnames               []string
	P2pPort                 int
	JoinExpiry              int64
	WithoutGasCosts         bool
	WithoutNonces           bool
	VoteExpiry              int64
	Allocs                  map[string]*big.Int
	FundNonValidators       bool
	Extensions              []map[string]map[string]string // for each node
}

Jump to

Keyboard shortcuts

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