utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllContainerNames added in v0.3.0

func AllContainerNames() []string

AllContainerNames returns every container name any registered network can run as, including alternates. Use it (not NetworkContainerMap) wherever the question is "is any nodevin node running or storing data?".

func CandidateContainerNames added in v0.3.0

func CandidateContainerNames(network string) []string

CandidateContainerNames returns every container name network's primary service may run as, default first. It is nil for an unknown network.

func CheckIfTestnetOrTestnetNetworkFlag

func CheckIfTestnetOrTestnetNetworkFlag() bool

func ComponentNetworks added in v0.3.0

func ComponentNetworks(network string) []string

ComponentNetworks returns the networks that run inside network's stack.

func ExpandHomeDir added in v0.2.0

func ExpandHomeDir(path string) (string, error)

Expands a leading "~" or "~/" in path to the current user's home directory. filepath.Join and os.MkdirAll treat "~" as a literal directory name, not a shell shortcut, so a value like "~/Desktop" must be expanded manually before use or it silently creates a "~" directory relative to the current working directory instead of resolving to the user's home.

func ExplicitContainerName added in v0.3.0

func ExplicitContainerName(network string) (string, error)

ExplicitContainerName is ResolveContainerName for destructive commands: for a network with selectable clients it requires the client to be named with its flag, and never infers it. Other networks resolve as usual.

func FindComposeFile added in v0.3.0

func FindComposeFile(containerName string) (string, error)

FindComposeFile locates the docker-compose file nodevin generated for a container ("docker-compose_<container>.yml"). It looks in the nodevin data directory first, which honors --data-dir, then in the directory of the nodevin executable and the current directory, where older versions wrote them.

func FindComposeFileForContainer added in v0.3.0

func FindComposeFileForContainer(container string) (string, error)

FindComposeFileForContainer locates the compose file that manages container. A container that runs inside another network's stack (a consensus client) is managed by that stack's compose file.

func GetAllSupportedNetworks

func GetAllSupportedNetworks() string

func GetCommandSupportedNetworks added in v0.0.5

func GetCommandSupportedNetworks() string

func GetDefaultLocalMappedContainerName

func GetDefaultLocalMappedContainerName(network string) (string, bool)

func GetFiftysixDockerhubContainerName

func GetFiftysixDockerhubContainerName(network string) (string, bool)

func GetNetworkRequiredDataSize

func GetNetworkRequiredDataSize(network string) (int, bool)

func GetNetworkRequiredSnapshotSize

func GetNetworkRequiredSnapshotSize(network string) (int, bool)

func GetNodevinDataDir

func GetNodevinDataDir() (string, error)

Returns path to the user's nodevin data directory (~/.nodevin/data)

func GetNodevinExecutable added in v0.0.5

func GetNodevinExecutable() string

func GetSizeDescription

func GetSizeDescription(size int64) string

func GetSnapshotCIDByNetwork added in v0.0.7

func GetSnapshotCIDByNetwork(network string) (string, bool)

func GetStartMessage

func GetStartMessage(network string) (string, bool)

func IsEthereumExecutionClient added in v0.3.0

func IsEthereumExecutionClient(name string) bool

IsEthereumExecutionClient reports whether name is one of the container names the "ethereum" network can run its execution client as.

func IsSupportedExtendedInfoSoftware added in v0.0.7

func IsSupportedExtendedInfoSoftware(software string) bool

func NetworkContainerMap

func NetworkContainerMap() map[string]string

func NetworkDefaultRPCPorts

func NetworkDefaultRPCPorts() map[string]int

func ResolveContainerName added in v0.3.0

func ResolveContainerName(network string) (string, error)

ResolveContainerName returns the container that currently represents network. For most networks that is just the registry's ContainerName. For a network whose primary service can run as one of several clients it discovers which one, in order: the explicit --<ClientFlag> value, the one running right now, the one that has a data directory or compose file, and finally the default. If several match at a step it returns *AmbiguousClientError rather than guessing.

func RunningContainerNames added in v0.3.0

func RunningContainerNames() ([]string, error)

RunningContainerNames returns the names of all running Docker containers.

func StackOwner added in v0.3.0

func StackOwner(network string) (string, bool)

StackOwner returns the network whose compose stack network runs inside (e.g. "ethereum" for "lighthouse"), if any.

Types

type AmbiguousClientError added in v0.3.0

type AmbiguousClientError struct {
	Network    string
	Flag       string
	Candidates []string
	// Running is true when the candidates are running right now, false when
	// they are only present on disk (data directory or compose file).
	Running bool
}

AmbiguousClientError means a network can run as several containers (see NetworkInfo.AlternateContainerNames) and more than one of them is present, so nodevin will not guess which one the user means.

func (*AmbiguousClientError) Error added in v0.3.0

func (e *AmbiguousClientError) Error() string

type NetworkInfo

type NetworkInfo struct {
	ContainerName string
	// AlternateContainerNames are other containers the network's primary
	// service may run as (e.g. Ethereum's execution client is chosen with
	// --execution-client). ContainerName is the default. See ResolveContainerName.
	AlternateContainerNames []string
	// ClientFlag names the CLI flag that selects between ContainerName and
	// AlternateContainerNames.
	ClientFlag string
	// PartOf marks a network that only ever runs inside another network's
	// compose stack (e.g. lighthouse inside ethereum): it has no compose file
	// of its own and cannot be stopped independently.
	PartOf           string
	DockerHubImage   string
	SnapshotCID      string
	RPCPort          int
	DataSize         int
	SnapshotSize     int
	StartMessage     string
	CommandSupported bool
}

Jump to

Keyboard shortcuts

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