internal

package
v0.0.0-...-818b14e Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainNetwork string = "main"
	TestNetwork string = "test"
	DevNetwork  string = "dev"
	QaNetwork   string = "qa"
)

Variables

View Source
var SubstrateURLs = map[string][]string{
	TestNetwork: {"wss://tfchain.test.grid.tf/ws", "wss://tfchain.test.grid.tf:443"},
	MainNetwork: {"wss://tfchain.grid.tf/ws", "wss://tfchain.grid.tf:443"},
	DevNetwork:  {"wss://tfchain.dev.grid.tf/ws", "wss://tfchain.dev.grid.tf:443"},
	QaNetwork:   {"wss://tfchain.qa.grid.tf/ws", "wss://tfchain.qa.grid.tf:443"},
}

SubstrateURLs for substrate urls

Functions

func GetIdentityWithKeyType

func GetIdentityWithKeyType(mnemonicOrSeed, keyType string) (identity substrate.Identity, err error)

GetIdentityWithKeyType returns chain identity given a key type. key type can be "ed25519" or "sr25519"

Types

type Config

type Config struct {
	FarmID                  uint32   `yaml:"farm_id"`
	IncludedNodes           []uint32 `yaml:"included_nodes"`
	ExcludedNodes           []uint32 `yaml:"excluded_nodes"`
	PriorityNodes           []uint32 `yaml:"priority_nodes"`
	NeverShutDownNodes      []uint32 `yaml:"never_shutdown_nodes"`
	Power                   power    `yaml:"power"`
	ContinueOnPoweringOnErr bool
}

Config is the inputs for configuration for farmerbot

type FarmerBot

type FarmerBot struct {
	// contains filtered or unexported fields
}

FarmerBot for managing farms

func NewFarmerBot

func NewFarmerBot(ctx context.Context, config Config, network, mnemonicOrSeed, keyType string) (FarmerBot, error)

NewFarmerBot generates a new farmer bot

func (*FarmerBot) Run

func (f *FarmerBot) Run(ctx context.Context) error

Run runs farmerbot to update nodes and power management

type NodeFilterOption

type NodeFilterOption struct {
	NodesExcluded []uint32 `json:"nodes_excluded,omitempty"`
	NumGPU        uint8    `json:"num_gpu,omitempty"`
	GPUVendors    []string `json:"gpu_vendors,omitempty"`
	GPUDevices    []string `json:"gpu_devices,omitempty"`
	GPUVram       uint64   `json:"gpu_vram,omitempty"`
	Certified     bool     `json:"certified,omitempty"`
	Dedicated     bool     `json:"dedicated,omitempty"`
	PublicConfig  bool     `json:"public_config,omitempty"`
	PublicIPs     uint64   `json:"public_ips,omitempty"`
	HRU           uint64   `json:"hru,omitempty"` // in GB
	SRU           uint64   `json:"sru,omitempty"` // in GB
	CRU           uint64   `json:"cru,omitempty"`
	MRU           uint64   `json:"mru,omitempty"` // in GB
}

NodeFilterOption represents the options to find a node

type NodeReport

type NodeReport struct {
	ID                           uint32        `json:"id"`
	State                        string        `json:"state"`
	HasActiveRentContract        bool          `json:"rented"`
	HasActiveContracts           bool          `json:"has_active_contracts"`
	Dedicated                    bool          `json:"dedicated"`
	PublicConfig                 bool          `json:"public_config"`
	CRUUsagePercentage           uint8         `json:"cru_usage_percentage"`
	SRUUsagePercentage           uint8         `json:"sru_usage_percentage"`
	MRUUsagePercentage           uint8         `json:"mru_usage_percentage"`
	HRUUsagePercentage           uint8         `json:"hru_usage_percentage"`
	TimesRandomWakeUps           int           `json:"random_wakeups"`
	SincePowerStateChanged       time.Duration `json:"since_power_state_changed"`
	SinceLastTimeAwake           time.Duration `json:"since_last_time_awake"`
	LastTimePeriodicWakeUp       time.Time     `json:"last_time_periodic_wakeup"`
	UntilClaimedResourcesTimeout time.Duration `json:"until_claimed_resources_timeout"`
}

NodeReport is a report for some node info

type ProxyClient

type ProxyClient interface {
	Node(ctx context.Context, nodeID uint32) (res types.NodeWithNestedCapacity, err error)
}

Substrate is substrate client interface

type RMB

type RMB interface {
	Statistics(ctx context.Context, nodeTwin uint32) (stats pkg.Counters, err error)
	GetStoragePools(ctx context.Context, nodeTwin uint32) (pools []pkg.PoolMetrics, err error)
	ListGPUs(ctx context.Context, nodeTwin uint32) (gpus []pkg.GPU, err error)
}

RMB is an rmb abstract client interface.

type RMBNodeClient

type RMBNodeClient struct {
	// contains filtered or unexported fields
}

func NewRmbNodeClient

func NewRmbNodeClient(rmb rmb.Client) *RMBNodeClient

func (*RMBNodeClient) GetStoragePools

func (r *RMBNodeClient) GetStoragePools(ctx context.Context, nodeTwin uint32) (pools []pkg.PoolMetrics, err error)

GetStoragePools executes zos system version cmd

func (*RMBNodeClient) ListGPUs

func (r *RMBNodeClient) ListGPUs(ctx context.Context, nodeTwin uint32) (gpus []pkg.GPU, err error)

ListGPUs return a list of all gpus on the node.

func (*RMBNodeClient) Statistics

func (r *RMBNodeClient) Statistics(ctx context.Context, nodeTwin uint32) (stats pkg.Counters, err error)

Statistics returns some node statistics. Including total and available cpu, memory, storage, etc...

type Substrate

type Substrate interface {
	SetNodePowerTarget(identity substrate.Identity, nodeID uint32, up bool) (hash types.Hash, err error)
	GetPowerTarget(nodeID uint32) (power substrate.NodePower, err error)

	GetNodeRentContract(nodeID uint32) (uint64, error)
	GetNodeContracts(nodeID uint32) ([]types.U64, error)
	GetNode(nodeID uint32) (*substrate.Node, error)
	GetFarm(id uint32) (*substrate.Farm, error)
	GetNodes(farmID uint32) ([]uint32, error)
	GetDedicatedNodePrice(nodeID uint32) (uint64, error)
	GetTwinByPubKey(publicKey []byte) (uint32, error)
}

Substrate is substrate client interface

type ThresholdPercentages

type ThresholdPercentages struct {
	CRU float64 `yaml:"cru"`
	SRU float64 `yaml:"sru"`
	MRU float64 `yaml:"mru"`
	HRU float64 `yaml:"hru"`
}

ThresholdPercentages are the wakeUp threshold for each resource type

Jump to

Keyboard shortcuts

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