miners

package
v0.0.0-...-2a3eace Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package miners provides functionality for discovering and controlling cryptocurrency miners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvalonLiteStats

type AvalonLiteStats struct {
	Ver          string         `json:"ver"`
	LVer         string         `json:"lver"`
	BVer         string         `json:"bver"`
	HashMcu0Ver  string         `json:"hash_mcu0_ver"`
	FanMcuVer    string         `json:"fan_mcu_ver"`
	CPU          string         `json:"cpu"`
	FW           string         `json:"fw"`
	DNA          string         `json:"dna"`
	State        AvalonState    `json:"state"`
	MemFree      int            `json:"mem_free"`
	NetFail      []int64        `json:"net_fail"`
	SSID         string         `json:"ssid"`
	RSSI         int            `json:"rssi"`
	NetDevType   int            `json:"net_dev_type"`
	SystemStatus string         `json:"system_status"`
	Elapsed      int64          `json:"elapsed"`
	BootBy       string         `json:"boot_by"`
	LW           int64          `json:"lw"`
	MH           int            `json:"mh"`
	DHW          int            `json:"dhw"`
	HW           int            `json:"hw"`
	DH           string         `json:"dh"`
	ITemp        int            `json:"itemp"`
	HBITemp      int            `json:"hbi_temp"`
	HBOTemp      int            `json:"hbo_temp"`
	TMax         int            `json:"tmax"`
	TAvg         int            `json:"tavg"`
	TarT         int            `json:"tart"`
	Fan1         int            `json:"fan1"`
	Fan2         int            `json:"fan2"`
	Fan3         int            `json:"fan3"`
	Fan4         int            `json:"fan4"`
	FanR         int            `json:"fanr"`
	SoftOffTime  int64          `json:"soft_off_time"`
	SoftOnTime   int64          `json:"soft_on_time"`
	Filter       int            `json:"filter"`
	FanErr       int            `json:"fan_err"`
	SoloAllowed  int            `json:"solo_allowed"`
	PS           []int          `json:"ps"`
	PCommE       int            `json:"pcomm_e"`
	GHSspd       float64        `json:"ghs_spd"`
	DHspd        string         `json:"dh_spd"`
	GHSmm        float64        `json:"ghs_mm"`
	GHSavg       float64        `json:"ghs_avg"`
	WU           float64        `json:"wu"`
	Freq         float64        `json:"freq"`
	MGHS         float64        `json:"mghs"`
	TA           int            `json:"ta"`
	Core         string         `json:"core"`
	BIN          int            `json:"bin"`
	PING         int            `json:"ping"`
	SoftOFF      int            `json:"soft_off"`
	ECHU         int            `json:"echu"`
	ECMM         int            `json:"ecmm"`
	PLL0         []int          `json:"pll0"`
	SF0          []int          `json:"sf0"`
	CRC          int            `json:"crc"`
	COMCRC       int            `json:"comcrc"`
	ATA0         string         `json:"ata0"`
	LcdOnoff     int            `json:"lcd_onoff"`
	Activation   int            `json:"activation"`
	WorkMode     AvalonWorkMode `json:"work_mode"`
	WorkLevel    int            `json:"work_level"`
	MPO          int            `json:"mpo"`
	CALIALL      int            `json:"caliall"`
	ADJ          int            `json:"adj"`
	NonceMask    int            `json:"nonce_mask"`
}

AvalonLiteStats represents detailed statistics from an Avalon miner.

type AvalonQCommand

type AvalonQCommand struct {
	Command string `json:"command"`
}

AvalonQCommand represents a command to send to an Avalon miner.

type AvalonQHost

type AvalonQHost struct {
	Address          string
	Port             int
	Version          *AvalonQVersion
	LiteStatsHistory []*AvalonLiteStats
	LastStatsError   error
	LastStats        *AvalonLiteStats
}

AvalonQHost represents an Avalon miner host with its connection details and statistics.

func Discover

func Discover(ctx context.Context, network string) []*AvalonQHost

Discover searches for Avalon miners on the specified network and returns a list of discovered hosts.

func (*AvalonQHost) AddLiteStats

func (h *AvalonQHost) AddLiteStats(stats *AvalonLiteStats, err error)

AddLiteStats appends a new AvalonLiteStats to the history and keeps only the last 5 entries.

func (*AvalonQHost) RefreshLiteStats

func (h *AvalonQHost) RefreshLiteStats(ctx context.Context)

RefreshLiteStats refreshes the lite statistics for the Avalon miner.

func (*AvalonQHost) ResetLiteStats

func (h *AvalonQHost) ResetLiteStats()

ResetLiteStats keeps only the latest stats in history.

func (*AvalonQHost) SetWorkMode

func (h *AvalonQHost) SetWorkMode(ctx context.Context, mode AvalonWorkMode, resetHistory bool) (string, error)

SetWorkMode sets the work mode of the Avalon miner.

func (*AvalonQHost) Standby

func (h *AvalonQHost) Standby(ctx context.Context) (string, error)

Standby puts the Avalon miner into standby mode.

func (*AvalonQHost) WakeUp

func (h *AvalonQHost) WakeUp(ctx context.Context) (string, error)

WakeUp wakes up the Avalon miner from standby mode.

type AvalonQLiteStats

type AvalonQLiteStats struct {
	Status []StatusItem `json:"STATUS"`
	Stats  []StatsItem  `json:"STATS"`
	ID     int          `json:"id"`
}

AvalonQLiteStats represents lite statistics response from an Avalon miner.

type AvalonQVersion

type AvalonQVersion struct {
	Status  []StatusItem  `json:"STATUS"`
	Version []VersionItem `json:"VERSION"`
	ID      int           `json:"id"`
}

AvalonQVersion represents version information from an Avalon miner.

type AvalonState

type AvalonState int

AvalonState represents the state of an Avalon miner

const (
	AvalonStateRunning AvalonState = 0 // Running
	AvalonStateMining  AvalonState = 1 // Mining
	AvalonStateStandBy AvalonState = 2 // StandBy
)

Avalon miner state constants

func (AvalonState) IsValid

func (s AvalonState) IsValid() bool

IsValid returns true if the AvalonState is a valid state

func (AvalonState) String

func (s AvalonState) String() string

String returns the string representation of the AvalonState

type AvalonWorkMode

type AvalonWorkMode int

AvalonWorkMode represents the work mode of an Avalon miner

const (
	AvalonEcoMode      AvalonWorkMode = 0 // Eco
	AvalonStandardMode AvalonWorkMode = 1 // Standard
	AvalonSuperMode    AvalonWorkMode = 2 // Super
)

Avalon miner work mode constants

func (AvalonWorkMode) String

func (w AvalonWorkMode) String() string

String returns the string representation of the AvalonWorkMode

type Receiver

type Receiver[T any] func(conn net.Conn) (T, error)

Receiver is a generic function type for receiving data over a network connection.

type Sender

type Sender func(conn net.Conn) error

Sender is a function type for sending data over a network connection.

type StatsItem

type StatsItem struct {
	MMIDSummary *AvalonLiteStats `json:"-"`
}

StatsItem represents a statistics item from an Avalon miner.

func (*StatsItem) UnmarshalJSON

func (s *StatsItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for StatsItem.

type StatusItem

type StatusItem struct {
	Status      string `json:"STATUS"`
	When        int64  `json:"When"`
	Code        int    `json:"Code"`
	Msg         string `json:"Msg"`
	Description string `json:"Description"`
}

StatusItem represents a status response item from an Avalon miner.

type VersionItem

type VersionItem struct {
	CGMiner       string `json:"CGMiner"`
	API           string `json:"API"`
	Prod          string `json:"PROD"`
	Model         string `json:"MODEL"`
	HWType        string `json:"HWTYPE"`
	SWType        string `json:"SWTYPE"`
	LVersion      string `json:"LVERSION"`
	BVersion      string `json:"BVERSION"`
	CGVersion     string `json:"CGVERSION"`
	HBMcuVersion  string `json:"HBMCUVERSION"`
	FANMcuVersion string `json:"FANMCUVERSION"`
	DNA           string `json:"DNA"`
	MAC           string `json:"MAC"`
}

VersionItem represents version details from an Avalon miner.

Jump to

Keyboard shortcuts

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