nodecfg

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 20 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
	// (JSON-RPC, HTTP, Admin, P2P, node 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
	Allocs           map[string]*big.Int
	VoteExpiry       int64
	Extensions       map[string]map[string]string
	Forks            map[string]*uint64
	AuthenticateRPCs bool
}

func (*NodeGenerateConfig) ApplyGenesisParams added in v0.9.0

func (genCfg *NodeGenerateConfig) ApplyGenesisParams(genesisCfg *chain.GenesisConfig)

type TestnetGenerateConfig

type TestnetGenerateConfig struct {
	ChainID       string
	BlockInterval time.Duration
	// InitialHeight           int64
	AdminAddress string
	AdminNoTLS   bool

	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
	VoteExpiry              int64
	Allocs                  map[string]*big.Int
	FundNonValidators       bool
	Extensions              []map[string]map[string]string // for each node
	SnapshotsEnabled        bool
	MaxSnapshots            uint64
	SnapshotHeights         uint64
	Forks                   map[string]*uint64
	PrivateMode             bool
	PrivateRPC              bool
}

Jump to

Keyboard shortcuts

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