utils

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: BSD-3-Clause Imports: 25 Imported by: 37

Documentation

Overview

Copyright (C) 2022, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyExecPath    = errors.New("the path to the avalanchego executable is not defined. please make sure to either set the AVALANCHEGO_EXEC_PATH environment variable or pass the path with the --avalanchego-path flag")
	ErrNotExists        = errors.New("the avalanchego executable does not exists at the provided path")
	ErrNotExistsPlugin  = errors.New("the vm plugin does not exists at the provided path. please check if the plugin path is set correctly in the AVALANCHEGO_PLUGIN_PATH environment variable or the --plugin-dir flag and if the plugin binary is located there")
	ErrorNoNetworkIDKey = fmt.Errorf("couldn't find key %q in genesis", genesisNetworkIDKey)
)

Functions

func BeaconMapFromSet added in v1.9.0

func BeaconMapFromSet(beaconSet beacon.Set) (map[ids.NodeID]netip.AddrPort, error)

func BeaconMapToSet added in v1.9.0

func BeaconMapToSet(beaconMap map[ids.NodeID]netip.AddrPort) (beacon.Set, error)

func CheckExecPath

func CheckExecPath(exec string) error

func CheckPluginPath added in v1.5.0

func CheckPluginPath(pluginExec string) error

func ColorAndPrepend

func ColorAndPrepend(reader io.Reader, writer io.Writer, prependText string, color logging.Color)

ColorAndPrepend reads each line from [reader], prepends it with [prependText] and colors it with [color], and then prints the prepended/colored line to [writer].

func CombineJSONs added in v1.9.0

func CombineJSONs(baseJSON string, addedJSON string) (string, error)

func DirnameWithTimestamp added in v1.9.0

func DirnameWithTimestamp(dirPrefix string) string

func FileExists added in v1.9.0

func FileExists(filename string) bool

FileExists checks if a file exists.

func GenerateGenesis added in v1.9.0

func GenerateGenesis(
	networkID uint32,
	nodeKeys []*NodeKeys,
) ([]byte, error)

func IsCustomNetwork added in v1.9.0

func IsCustomNetwork(networkID uint32) bool

func IsInsideDockerContainer added in v1.9.0

func IsInsideDockerContainer() (bool, error)

func IsPublicNetwork added in v1.9.0

func IsPublicNetwork(networkID uint32) bool

func MkDirWithTimestamp

func MkDirWithTimestamp(dirPrefix string) (string, error)

func NetworkIDFromGenesis

func NetworkIDFromGenesis(genesis []byte) (uint32, error)

Returns the network ID in the given genesis

func NewColorPicker

func NewColorPicker() *colorPicker

NewColorPicker allows to assign a color to different clients

func PathExists added in v1.9.0

func PathExists(path string) (bool, error)

func SetGenesisNetworkID added in v1.9.0

func SetGenesisNetworkID(genesis []byte, networkID uint32) ([]byte, error)

func SetJSONKey

func SetJSONKey(jsonBody string, k string, v string) (string, error)

Set k=v in JSON string e.g., "track-subnets" is the key and value is "a,b,c".

func ToNodeID

func ToNodeID(stakingKey, stakingCert []byte) (ids.NodeID, error)

func VMID

func VMID(vmName string) (ids.ID, error)

func VerifySubnetHasCorrectParticipants added in v1.4.1

func VerifySubnetHasCorrectParticipants(
	log logging.Logger,
	subnetParticipants []string,
	cluster *rpcb.ClusterInfo,
	subnetID string,
) bool

func WaitForFile added in v1.9.0

func WaitForFile(
	filename string,
	timeout time.Duration,
	checkInterval time.Duration,
	description string,
) error

Types

type ColorPicker

type ColorPicker interface {
	// get the next color
	NextColor() logging.Color
}

ColorPicker allows to assign a new color

type EncodedNodeKeys added in v1.9.0

type EncodedNodeKeys struct {
	StakingKey  string
	StakingCert string
	BlsKey      string
}

func EncodeNodeKeys added in v1.9.0

func EncodeNodeKeys(key *NodeKeys) *EncodedNodeKeys

type NodeKeys added in v1.9.0

type NodeKeys struct {
	StakingKey  []byte
	StakingCert []byte
	BlsKey      []byte
}

func GenerateKeysForNodes added in v1.9.0

func GenerateKeysForNodes(num int) ([]*NodeKeys, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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