client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstallerName string = "install.sh"
	InstallerURL  string = "https://github.com/nodeset-org/hyperdrive/releases/download/%s/" + InstallerName

	SettingsFile       string = "user-settings.yml"
	BackupSettingsFile string = "user-settings-backup.yml"
)

Config

Variables

This section is empty.

Functions

func InstallService added in v1.1.0

func InstallService(opts InstallOptions) error

Install Hyperdrive

func LoadHyperdriveSettings added in v1.1.0

func LoadHyperdriveSettings(networksDir string) ([]*config.HyperdriveSettings, error)

Load the Hyperdrive settings from the network settings files on disk

func LoadStakeWiseSettings added in v1.1.0

func LoadStakeWiseSettings(networksDir string) ([]*swconfig.StakeWiseSettings, error)

Load the StakeWise settings from the network settings files on disk

func SaveConfig

func SaveConfig(cfg *GlobalConfig, directory string, filename string) error

Saves a config

func SyncRatioToPercent

func SyncRatioToPercent(in float64) float64

When printing sync percents, we should avoid printing 100%. This function is only called if we're still syncing, and the `%0.2f` token will round up if we're above 99.99%.

Types

type ConstellationClient added in v1.1.0

type ConstellationClient struct {
	Api     *csclient.ApiClient
	Context *context.HyperdriveContext
	Logger  *slog.Logger
}

Constellation client

func NewConstellationClientFromCtx added in v1.1.0

func NewConstellationClientFromCtx(c *cli.Context, hdClient *HyperdriveClient) (*ConstellationClient, error)

Create new Constellation client from CLI context Only use this function from commands that may work if the Daemon service doesn't exist

func (*ConstellationClient) GetServiceVersion added in v1.1.0

func (c *ConstellationClient) GetServiceVersion() (string, error)

Get the service version

type GlobalConfig added in v0.2.3

type GlobalConfig struct {
	ExternalIP string

	// Hyperdrive
	Hyperdrive          *hdconfig.HyperdriveConfig
	HyperdriveResources *hdconfig.MergedResources

	// StakeWise
	StakeWise          *swconfig.StakeWiseConfig
	StakeWiseResources *swconfig.StakeWiseResources

	// Constellation
	Constellation          *csconfig.ConstellationConfig
	ConstellationResources *csconfig.ConstellationResources
}

Wrapper for global configuration

func LoadConfigFromFile

func LoadConfigFromFile(configPath string, hdSettings []*config.HyperdriveSettings, swSettings []*swconfig.StakeWiseSettings, csSettings []*csconfig.ConstellationSettings) (*GlobalConfig, error)

Loads a config without updating it if it exists

func NewGlobalConfig added in v0.2.3

Make a new global config

func (*GlobalConfig) ChangeNetwork added in v0.2.3

func (c *GlobalConfig) ChangeNetwork(newNetwork config.Network)

Changes the current network, propagating new parameter settings if they are affected

func (*GlobalConfig) ConstellationApiKeyPath added in v1.1.0

func (c *GlobalConfig) ConstellationApiKeyPath() string

func (*GlobalConfig) CreateCopy added in v0.2.3

func (c *GlobalConfig) CreateCopy() *GlobalConfig

Creates a copy of the configuration

func (*GlobalConfig) DeserializeModules added in v0.2.3

func (c *GlobalConfig) DeserializeModules() error

Deserialize the config's modules (assumes the Hyperdrive config itself has already been deserialized)

func (*GlobalConfig) GetAllModuleConfigs added in v0.2.3

func (c *GlobalConfig) GetAllModuleConfigs() []hdconfig.IModuleConfig

Get the configs for all of the modules in the system

func (*GlobalConfig) GetChanges added in v0.2.3

func (c *GlobalConfig) GetChanges(oldConfig *GlobalConfig) ([]*config.ChangedSection, map[config.ContainerID]bool, bool)

Get all of the settings that have changed between an old config and this config, and get all of the containers that are affected by those changes - also returns whether or not the selected network was changed

func (*GlobalConfig) GetEnabledModuleConfigNames added in v0.2.3

func (c *GlobalConfig) GetEnabledModuleConfigNames() []string

Get the configs for all of the modules in the system that are enabled

func (*GlobalConfig) HyperdriveApiKeyPath added in v1.1.0

func (c *GlobalConfig) HyperdriveApiKeyPath() string

func (*GlobalConfig) LoadExternalIP added in v1.0.0

func (c *GlobalConfig) LoadExternalIP()

Attempts to load the system's external IP address

func (*GlobalConfig) ModulesDirectory added in v0.2.3

func (c *GlobalConfig) ModulesDirectory() string

func (*GlobalConfig) Serialize added in v0.2.3

func (c *GlobalConfig) Serialize() map[string]any

Serialize the config and all modules

func (*GlobalConfig) StakeWiseApiKeyPath added in v1.1.0

func (c *GlobalConfig) StakeWiseApiKeyPath() string

func (*GlobalConfig) UpdateDefaults added in v0.2.3

func (c *GlobalConfig) UpdateDefaults()

Updates the default parameters based on the current network value

func (*GlobalConfig) Validate added in v0.2.3

func (c *GlobalConfig) Validate() []string

Checks to see if the current configuration is valid; if not, returns a list of errors

func (*GlobalConfig) ValidatorsDirectory added in v0.2.3

func (c *GlobalConfig) ValidatorsDirectory() string

type HyperdriveClient

type HyperdriveClient struct {
	Api     *client.ApiClient
	Context *context.HyperdriveContext
	Logger  *slog.Logger
	// contains filtered or unexported fields
}

Hyperdrive client

func NewHyperdriveClientFromCtx

func NewHyperdriveClientFromCtx(c *cli.Context) (*HyperdriveClient, error)

Create new Hyperdrive client from CLI context

func NewHyperdriveClientFromHyperdriveCtx added in v1.1.0

func NewHyperdriveClientFromHyperdriveCtx(hdCtx *context.HyperdriveContext) (*HyperdriveClient, error)

Create new Hyperdrive client from a custom context

func (*HyperdriveClient) DeleteVolume

func (c *HyperdriveClient) DeleteVolume(volumeName string) error

Deletes a volume

func (*HyperdriveClient) DeployMetricsConfigurations added in v1.0.1

func (c *HyperdriveClient) DeployMetricsConfigurations(config *GlobalConfig) error

Create the metrics and modules folders, and deploy the config templates for Prometheus and Grafana

func (*HyperdriveClient) DownService added in v1.0.1

func (c *HyperdriveClient) DownService(composeFiles []string, includeVolumes bool) error

Stop the Hyperdrive service, shutting it down and removing the Docker artifacts

func (*HyperdriveClient) GenerateDaemonAuthKeys added in v1.1.0

func (c *HyperdriveClient) GenerateDaemonAuthKeys(config *GlobalConfig) error

Create the metrics and modules folders, and deploy the config templates for Prometheus and Grafana

func (*HyperdriveClient) GetClientVolumeName

func (c *HyperdriveClient) GetClientVolumeName(containerName, volumeTarget string) (string, error)

Gets the name of the client volume

func (*HyperdriveClient) GetClientVolumeSource

func (c *HyperdriveClient) GetClientVolumeSource(containerName string, volumeTarget string) (string, error)

Gets the absolute file path of the client volume

func (*HyperdriveClient) GetDirSizeViaEcMigrator

func (c *HyperdriveClient) GetDirSizeViaEcMigrator(container string, targetDir string, image string) (uint64, error)

Gets the size of the target directory via the EC migrator for importing, which should have the same permissions as exporting

func (*HyperdriveClient) GetDocker

func (c *HyperdriveClient) GetDocker() (*docker.Client, error)

Get the Docker client

func (*HyperdriveClient) GetDockerContainerShutdownTime

func (c *HyperdriveClient) GetDockerContainerShutdownTime(containerName string) (time.Time, error)

Get the time that the given container shut down

func (*HyperdriveClient) GetDockerImage

func (c *HyperdriveClient) GetDockerImage(containerName string) (string, error)

Get the current Docker image used by the given container

func (*HyperdriveClient) GetDockerStatus

func (c *HyperdriveClient) GetDockerStatus(containerName string) (string, error)

Get the current Docker image used by the given container

func (*HyperdriveClient) GetRunningContainers added in v1.0.0

func (c *HyperdriveClient) GetRunningContainers(projectName string) (map[string]bool, error)

Get a list of running project containers (values are always true, the map is just for quick name lookup)

func (*HyperdriveClient) GetServiceVersion

func (c *HyperdriveClient) GetServiceVersion() (string, error)

Get the Hyperdrive service version

func (*HyperdriveClient) GetValidatorContainers

func (c *HyperdriveClient) GetValidatorContainers(projectName string) ([]string, error)

Get the Docker images with the project ID as a prefix that run the VC start script in their command line arguments

func (*HyperdriveClient) GetVolumeSize

func (c *HyperdriveClient) GetVolumeSize(volumeName string) (int64, error)

Gets the disk usage of the given volume

func (*HyperdriveClient) LoadBackupConfig

func (c *HyperdriveClient) LoadBackupConfig() (*GlobalConfig, error)

Load the backup config

func (*HyperdriveClient) LoadConfig

func (c *HyperdriveClient) LoadConfig() (*GlobalConfig, bool, error)

Load the config Returns the global config and whether or not it was newly generated

func (*HyperdriveClient) PrintDaemonLogs added in v1.0.0

func (c *HyperdriveClient) PrintDaemonLogs(composeFiles []string, tail string, logPaths ...string) error

Print the Hyperdrive daemon logs

func (*HyperdriveClient) PrintServiceCompose

func (c *HyperdriveClient) PrintServiceCompose(composeFiles []string) error

Print the Hyperdrive service compose config

func (*HyperdriveClient) PrintServiceLogs

func (c *HyperdriveClient) PrintServiceLogs(composeFiles []string, tail string, serviceNames ...string) error

Print the Hyperdrive service logs

func (*HyperdriveClient) PrintServiceStatus

func (c *HyperdriveClient) PrintServiceStatus(composeFiles []string) error

Print the Hyperdrive service status

func (*HyperdriveClient) PurgeData

func (c *HyperdriveClient) PurgeData(composeFiles []string, restart bool) error

Deletes the data directory, including the node wallet and all validator keys, and restarts the Docker containers if requested

func (*HyperdriveClient) RemoveContainer

func (c *HyperdriveClient) RemoveContainer(containerName string) error

Deletes a container

func (*HyperdriveClient) RestartContainer

func (c *HyperdriveClient) RestartContainer(containerName string) error

Restart a container

func (*HyperdriveClient) RunEcMigrator

func (c *HyperdriveClient) RunEcMigrator(container string, volume string, targetDir string, mode string, image string) error

Runs the EC migrator

func (*HyperdriveClient) RunNethermindPruneStarter

func (c *HyperdriveClient) RunNethermindPruneStarter(container string) error

Runs the prune provisioner

func (*HyperdriveClient) RunPruneProvisioner

func (c *HyperdriveClient) RunPruneProvisioner(container string, volume string, image string) error

Runs the prune provisioner

func (*HyperdriveClient) SaveConfig

func (c *HyperdriveClient) SaveConfig(cfg *GlobalConfig) error

Save the config

func (*HyperdriveClient) StartContainer

func (c *HyperdriveClient) StartContainer(containerName string) error

Start a container

func (*HyperdriveClient) StartService

func (c *HyperdriveClient) StartService(composeFiles []string) error

Start the Hyperdrive service

func (*HyperdriveClient) StopContainer

func (c *HyperdriveClient) StopContainer(containerName string) error

Shut down a container

func (*HyperdriveClient) StopService

func (c *HyperdriveClient) StopService(composeFiles []string) error

Pause the Hyperdrive service, shutting it down without removing the Docker artifacts

func (*HyperdriveClient) TerminateService

func (c *HyperdriveClient) TerminateService(composeFiles []string, configPath string) error

Stop Hyperdrive and remove the config folder

type InstallOptions added in v1.1.0

type InstallOptions struct {
	RequireEscalation       bool
	Verbose                 bool
	NoDeps                  bool
	Version                 string
	InstallPath             string
	RuntimePath             string
	LocalInstallScriptPath  string
	LocalInstallPackagePath string
}

Options for installation

type StakewiseClient

type StakewiseClient struct {
	Api     *swclient.ApiClient
	Context *context.HyperdriveContext
	Logger  *slog.Logger
}

Stakewise client

func NewStakewiseClientFromCtx

func NewStakewiseClientFromCtx(c *cli.Context, hdClient *HyperdriveClient) (*StakewiseClient, error)

Create new Stakewise client from CLI context Only use this function from commands that may work if the Daemon service doesn't exist

func NewStakewiseClientFromHyperdriveCtx added in v1.1.0

func NewStakewiseClientFromHyperdriveCtx(hdCtx *context.HyperdriveContext, hdClient *HyperdriveClient) (*StakewiseClient, error)

Create new Stakewise client from a custom context Only use this function from commands that may work if the Daemon service doesn't exist

func (*StakewiseClient) GetServiceVersion added in v1.1.0

func (c *StakewiseClient) GetServiceVersion() (string, error)

Get the service version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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