cgminer

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 7 Imported by: 0

README

CGMiner API for Go

Installation

# install the library:
go get github.com/crypt0train/go-cgminer-api

// Use in your .go code:
import (
    cgminer "github.com/crypt0train/go-cgminer-api"
)

API Documentation

I started to completely rewrite forked code.

At this moment fully tested commands: Version(), Summary(), Stats() You can use runCommand(command string, parameter string) to run any command, that you want. Version and Summary sections have the same structure over the all devices, but Stats - it is something like hell.

Cgminer/Bmminer - is a best example of very bad JSON api and very bad code at all(it even has sprintf buffer overflow in "check" for a years). When you try get stats from cgminer via api, for a first time you can't parse the answer, because it's not valid and some portion of response of version command is mixed to the answer. Yep, fix this, but json response still invalid, float and integer values some times are presented as strings, sometimes you got "" instead of null value.

Command "stats" returned different output for each device, that i have tested S9, D3, L3+, T9+, even R1-LTC router. I wrote test for all of this, you can find textures in testdata folder.

My API method Stats() will return generic structure, that have all fields from all devices. I've created helpers to find data that depends on model, see example below.

Test coverage now: 58.4% of statements

Quickstart

package main

import (
    cgminer "github.com/crypt0train/go-cgminer-api"
    "log"
)

func main() {
    miner := cgminer.NewCGMiner("localhost", 4028, 2)
	stats, err := miner.Stats()
	if err != nil {
		log.Println(err)
	}
    fmt.Printf("%s | GHS avg: %0.2f\n", stats.Type, stats.GhsAverage)
    // When you connected to Antminer S9
    statsS9, _ := stats.S9()
	// When you connected to Antminer D3
    statsD3, _ := stats.D3()
	// When you connected to Antminer L3+
    statsL3, _ := stats.L3()
	// When you connected to Antminer T9+
    statsT9, _ := stats.T9()
	
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CGMiner

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

CGMiner - server deps

func NewCGMiner

func NewCGMiner(hostname string, port int64, timeout int) *CGMiner

NewCGMiner returns a CGMiner pointer, which is used to communicate with a running cgminer instance. Note that New does not attempt to connect to the miner.

func (*CGMiner) AddPool

func (miner *CGMiner) AddPool(url, username, password string) error

AddPool adds the given URL/username/password combination to the miner's pool list.

func (*CGMiner) Delete

func (miner *CGMiner) Delete(pool *Pool) error

func (*CGMiner) Devs

func (miner *CGMiner) Devs() (*[]Devs, error)

Devs returns basic information on the miner. See the Devs struct.

func (*CGMiner) Disable

func (miner *CGMiner) Disable(pool *Pool) error

func (*CGMiner) Enable

func (miner *CGMiner) Enable(pool *Pool) error

func (*CGMiner) Pools

func (miner *CGMiner) Pools() ([]Pool, error)

Pools returns a slice of Pool structs, one per pool.

func (*CGMiner) Quit

func (miner *CGMiner) Quit() error

func (*CGMiner) Restart

func (miner *CGMiner) Restart() error

func (*CGMiner) Stats

func (miner *CGMiner) Stats() (Stats, error)

Stats returns basic information on the miner. See the Stats struct.

func (*CGMiner) Summary

func (miner *CGMiner) Summary() (*Summary, error)

Summary returns basic information on the miner. See the Summary struct.

func (*CGMiner) SwitchPool

func (miner *CGMiner) SwitchPool(pool *Pool) error

func (*CGMiner) Version

func (miner *CGMiner) Version() (*Version, error)

Version - reply section VERSION

type Devs

type Devs struct {
	GPU                 int64
	Enabled             string
	Status              string
	Temperature         float64
	FanSpeed            int     `json:"Fan Speed"`
	FanPercent          int64   `json:"Fan Percent"`
	GPUClock            int64   `json:"GPU Clock"`
	MemoryClock         int64   `json:"Memory Clock"`
	GPUVoltage          float64 `json:"GPU Voltage"`
	Powertune           int64
	MHSav               float64 `json:"MHS av"`
	MHS5s               float64 `json:"MHS 5s"`
	Accepted            int64
	Rejected            int64
	HardwareErrors      int64 `json:"Hardware Errors"`
	Utility             float64
	Intensity           string
	LastSharePool       int64   `json:"Last Share Pool"`
	LashShareTime       int64   `json:"Lash Share Time"`
	TotalMH             float64 `json:"TotalMH"`
	Diff1Work           int64   `json:"Diff1 Work"`
	DifficultyAccepted  float64 `json:"Difficulty Accepted"`
	DifficultyRejected  float64 `json:"Difficulty Rejected"`
	LastShareDifficulty float64 `json:"Last Share Difficulty"`
	LastValidWork       int64   `json:"Last Valid Work"`
	DeviceHardware      float64 `json:"Device Hardware%"`
	DeviceRejected      float64 `json:"Device Rejected%"`
	DeviceElapsed       int64   `json:"Device Elapsed"`
}

Devs - device info

type GenericResponse

type GenericResponse struct {
	ID     int      `json:"id"`
	Status []Status `json:"STATUS"`
}

GenericResponse - default struct for all responses

type GenericStats

type GenericStats struct {
	BMMiner               string
	CGMiner               string `json:"CGMiner,omitempty"`
	Miner                 string
	CompileTime           string
	Type                  string
	MinerID               string `json:"miner_id"`
	MinerVersion          string `json:"miner_version"`
	MinerCount            int16  `json:"miner_count"`
	Elapsed               int64  `json:"Elapsed"`
	Wait                  float64
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	Stats                 int     `json:"STATS"`
	Max                   float64
	NotMatchingWork       int `json:"no_matching_work"`
	ID                    string
	Calls                 int
	Min                   float64
	TotalAcn              int16   `json:"total_acn"`
	TotalRate             float32 `json:"total_rate"`
	TotalRateIdeal        float32 `json:"total_rateideal"`
	TotalFrequencyAvg     float32 `json:"total_freqavg"`
	Frequency             float32 `json:"frequency,string"`
	FrequencyAvg1         float32 `json:"freq_avg1"`
	FrequencyAvg2         float32 `json:"freq_avg2"`
	FrequencyAvg3         float32 `json:"freq_avg3"`
	FrequencyAvg4         float32 `json:"freq_avg4"`
	FrequencyAvg5         float32 `json:"freq_avg5"`
	FrequencyAvg6         float32 `json:"freq_avg6"`
	FrequencyAvg7         float32 `json:"freq_avg7"`
	FrequencyAvg8         float32 `json:"freq_avg8"`
	FrequencyAvg9         float32 `json:"freq_avg9"`
	FrequencyAvg10        float32 `json:"freq_avg10"`
	FrequencyAvg11        float32 `json:"freq_avg11"`
	FrequencyAvg12        float32 `json:"freq_avg12"`
	FrequencyAvg13        float32 `json:"freq_avg13"`
	FrequencyAvg14        float32 `json:"freq_avg14"`
	FrequencyAvg15        float32 `json:"freq_avg15"`
	FrequencyAvg16        float32 `json:"freq_avg16"`
	FanNum                int16   `json:"fan_num"`
	Fan1                  int16   `json:"fan1"`
	Fan2                  int16   `json:"fan2"`
	Fan3                  int16   `json:"fan3"`
	Fan4                  int16   `json:"fan4"`
	Fan5                  int16   `json:"fan5"`
	Fan6                  int16   `json:"fan6"`
	Fan7                  int16   `json:"fan7"`
	Fan8                  int16   `json:"fan8"`
	TempMax               int16   `json:"temp_max"`
	TempNum               int16   `json:"temp_num"`
	Temp1                 int16   `json:"temp1"`
	Temp2                 int16   `json:"temp2"`
	Temp3                 int16   `json:"temp3"`
	Temp4                 int16   `json:"temp4"`
	Temp5                 int16   `json:"temp5"`
	Temp6                 int16   `json:"temp6"`
	Temp7                 int16   `json:"temp7"`
	Temp8                 int16   `json:"temp8"`
	Temp9                 int16   `json:"temp9"`
	Temp10                int16   `json:"temp10"`
	Temp11                int16   `json:"temp11"`
	Temp12                int16   `json:"temp12"`
	Temp13                int16   `json:"temp13"`
	Temp14                int16   `json:"temp14"`
	Temp15                int16   `json:"temp15"`
	Temp16                int16   `json:"temp16"`
	Temp2_1               int16   `json:"temp2_1"`
	Temp2_2               int16   `json:"temp2_2"`
	Temp2_3               int16   `json:"temp2_3"`
	Temp2_4               int16   `json:"temp2_4"`
	Temp2_5               int16   `json:"temp2_5"`
	Temp2_6               int16   `json:"temp2_6"`
	Temp2_7               int16   `json:"temp2_7"`
	Temp2_8               int16   `json:"temp2_8"`
	Temp2_9               int16   `json:"temp2_9"`
	Temp2_10              int16   `json:"temp2_10"`
	Temp2_11              int16   `json:"temp2_11"`
	Temp2_12              int16   `json:"temp2_12"`
	Temp2_13              int16   `json:"temp2_13"`
	Temp2_14              int16   `json:"temp2_14"`
	Temp2_15              int16   `json:"temp2_15"`
	Temp2_16              int16   `json:"temp2_16"`
	Temp3_1               int16   `json:"temp3_1"`
	Temp3_2               int16   `json:"temp3_2"`
	Temp3_3               int16   `json:"temp3_3"`
	Temp3_4               int16   `json:"temp3_4"`
	Temp3_5               int16   `json:"temp3_5"`
	Temp3_6               int16   `json:"temp3_6"`
	Temp3_7               int16   `json:"temp3_7"`
	Temp3_8               int16   `json:"temp3_8"`
	Temp3_9               int16   `json:"temp3_9"`
	Temp3_10              int16   `json:"temp3_10"`
	Temp3_11              int16   `json:"temp3_11"`
	Temp3_12              int16   `json:"temp3_12"`
	Temp3_13              int16   `json:"temp3_13"`
	Temp3_14              int16   `json:"temp3_14"`
	Temp3_15              int16   `json:"temp3_15"`
	Temp3_16              int16   `json:"temp3_16"`
	// this from L3+
	Temp31  int16 `json:"temp31"`
	Temp32  int16 `json:"temp32"`
	Temp33  int16 `json:"temp33"`
	Temp34  int16 `json:"temp34"`
	Temp4_1 int16 `json:"temp4_1"`
	Temp4_2 int16 `json:"temp4_2"`
	Temp4_3 int16 `json:"temp4_3"`
	Temp4_4 int16 `json:"temp4_4"`
	// interfcace{} - because S7 has valid value, but all others have quoted value
	Ghs5s      interface{} `json:"GHS 5s"`
	GhsAverage float64     `json:"GHS av"`
	ChainHW1   int         `json:"chain_hw1"`
	ChainHW2   int         `json:"chain_hw2"`
	ChainHW3   int         `json:"chain_hw3"`
	ChainHW4   int         `json:"chain_hw4"`
	ChainHW5   int         `json:"chain_hw5"`
	ChainHW6   int         `json:"chain_hw6"`
	ChainHW7   int         `json:"chain_hw7"`
	ChainHW8   int         `json:"chain_hw8"`
	ChainHW9   int         `json:"chain_hw9"`
	ChainHW10  int         `json:"chain_hw10"`
	ChainHW11  int         `json:"chain_hw11"`
	ChainHW12  int         `json:"chain_hw12"`
	ChainHW13  int         `json:"chain_hw13"`
	ChainHW14  int         `json:"chain_hw14"`
	ChainHW15  int         `json:"chain_hw15"`
	ChainHW16  int         `json:"chain_hw16"`
	ChainAcs1  string      `json:"chain_acs1"`
	ChainAcs2  string      `json:"chain_acs2"`
	ChainAcs3  string      `json:"chain_acs3"`
	ChainAcs4  string      `json:"chain_acs4"`
	ChainAcs5  string      `json:"chain_acs5"`
	ChainAcs6  string      `json:"chain_acs6"`
	ChainAcs7  string      `json:"chain_acs7"`
	ChainAcs8  string      `json:"chain_acs8"`
	ChainAcs9  string      `json:"chain_acs9"`
	ChainAcs10 string      `json:"chain_acs10"`
	ChainAcs11 string      `json:"chain_acs11"`
	ChainAcs12 string      `json:"chain_acs12"`
	ChainAcs13 string      `json:"chain_acs13"`
	ChainAcs14 string      `json:"chain_acs14"`
	ChainAcs15 string      `json:"chain_acs15"`
	ChainAcs16 string      `json:"chain_acs16"`
	ChainAcn1  int         `json:"chain_acn1"`
	ChainAcn2  int         `json:"chain_acn2"`
	ChainAcn3  int         `json:"chain_acn3"`
	ChainAcn4  int         `json:"chain_acn4"`
	ChainAcn5  int         `json:"chain_acn5"`
	ChainAcn6  int         `json:"chain_acn6"`
	ChainAcn7  int         `json:"chain_acn7"`
	ChainAcn8  int         `json:"chain_acn8"`
	ChainAcn9  int         `json:"chain_acn9"`
	ChainAcn10 int         `json:"chain_acn10"`
	ChainAcn11 int         `json:"chain_acn11"`
	ChainAcn12 int         `json:"chain_acn12"`
	ChainAcn13 int         `json:"chain_acn13"`
	ChainAcn14 int         `json:"chain_acn14"`
	ChainAcn15 int         `json:"chain_acn15"`
	ChainAcn16 int         `json:"chain_acn16"`
	// json.Number because we cannot parse empty string "" to float
	// S9(), D3() and other interface methods will correct represent this value as float32
	ChainRate1       json.Number `json:"chain_rate1"`
	ChainRate2       json.Number `json:"chain_rate2"`
	ChainRate3       json.Number `json:"chain_rate3"`
	ChainRate4       json.Number `json:"chain_rate4"`
	ChainRate5       json.Number `json:"chain_rate5"`
	ChainRate6       json.Number `json:"chain_rate6"`
	ChainRate7       json.Number `json:"chain_rate7"`
	ChainRate8       json.Number `json:"chain_rate8"`
	ChainRate9       json.Number `json:"chain_rate9"`
	ChainRate10      json.Number `json:"chain_rate10"`
	ChainRate11      json.Number `json:"chain_rate11"`
	ChainRate12      json.Number `json:"chain_rate12"`
	ChainRate13      json.Number `json:"chain_rate13"`
	ChainRate14      json.Number `json:"chain_rate14"`
	ChainRate15      json.Number `json:"chain_rate15"`
	ChainRate16      json.Number `json:"chain_rate16"`
	ChainRateIdeal1  float32     `json:"chain_rateideal1"`
	ChainRateIdeal2  float32     `json:"chain_rateideal2"`
	ChainRateIdeal3  float32     `json:"chain_rateideal3"`
	ChainRateIdeal4  float32     `json:"chain_rateideal4"`
	ChainRateIdeal5  float32     `json:"chain_rateideal5"`
	ChainRateIdeal6  float32     `json:"chain_rateideal6"`
	ChainRateIdeal7  float32     `json:"chain_rateideal7"`
	ChainRateIdeal8  float32     `json:"chain_rateideal8"`
	ChainRateIdeal9  float32     `json:"chain_rateideal9"`
	ChainRateIdeal10 float32     `json:"chain_rateideal10"`
	ChainRateIdeal11 float32     `json:"chain_rateideal11"`
	ChainRateIdeal12 float32     `json:"chain_rateideal12"`
	ChainRateIdeal13 float32     `json:"chain_rateideal13"`
	ChainRateIdeal14 float32     `json:"chain_rateideal14"`
	ChainRateIdeal15 float32     `json:"chain_rateideal15"`
	ChainRateIdeal16 float32     `json:"chain_rateideal16"`
	ChainOpenCore1   int         `json:"chain_opencore_1,string"`
	ChainOpenCore2   int         `json:"chain_opencore_2,string"`
	ChainOpenCore3   int         `json:"chain_opencore_3,string"`
	ChainOpenCore4   int         `json:"chain_opencore_4,string"`
	ChainOpenCore5   int         `json:"chain_opencore_5,string"`
	ChainOpenCore6   int         `json:"chain_opencore_6,string"`
	ChainOpenCore7   int         `json:"chain_opencore_7,string"`
	ChainOpenCore8   int         `json:"chain_opencore_8,string"`
	ChainOpenCore9   int         `json:"chain_opencore_9,string"`
	ChainOpenCore10  int         `json:"chain_opencore_10,string"`
	ChainOpenCore11  int         `json:"chain_opencore_11,string"`
	ChainOpenCore12  int         `json:"chain_opencore_12,string"`
	ChainOpenCore13  int         `json:"chain_opencore_13,string"`
	ChainOpenCore14  int         `json:"chain_opencore_14,string"`
	ChainOpenCore15  int         `json:"chain_opencore_15,string"`
	ChainOpenCore16  int         `json:"chain_opencore_16,string"`
	ChainOffside1    int         `json:"chain_offside_1,string"`
	ChainOffside2    int         `json:"chain_offside_2,string"`
	ChainOffside3    int         `json:"chain_offside_3,string"`
	ChainOffside4    int         `json:"chain_offside_4,string"`
	ChainOffside5    int         `json:"chain_offside_5,string"`
	ChainOffside6    int         `json:"chain_offside_6,string"`
	ChainOffside7    int         `json:"chain_offside_7,string"`
	ChainOffside8    int         `json:"chain_offside_8,string"`
	ChainOffside9    int         `json:"chain_offside_9,string"`
	ChainOffside10   int         `json:"chain_offside_10,string"`
	ChainOffside11   int         `json:"chain_offside_11,string"`
	ChainOffside12   int         `json:"chain_offside_12,string"`
	ChainOffside13   int         `json:"chain_offside_13,string"`
	ChainOffside14   int         `json:"chain_offside_14,string"`
	ChainOffside15   int         `json:"chain_offside_15,string"`
	ChainOffside16   int         `json:"chain_offside_16,string"`
	ChainXtime1      string      `json:"chain_xtime1"`
	ChainXtime2      string      `json:"chain_xtime2"`
	ChainXtime3      string      `json:"chain_xtime3"`
	ChainXtime4      string      `json:"chain_xtime4"`
	ChainXtime5      string      `json:"chain_xtime5"`
	ChainXtime6      string      `json:"chain_xtime6"`
	ChainXtime7      string      `json:"chain_xtime7"`
	ChainXtime8      string      `json:"chain_xtime8"`
	ChainXtime9      string      `json:"chain_xtime9"`
	ChainXtime10     string      `json:"chain_xtime10"`
	ChainXtime11     string      `json:"chain_xtime11"`
	ChainXtime12     string      `json:"chain_xtime12"`
	ChainXtime13     string      `json:"chain_xtime13"`
	ChainXtime14     string      `json:"chain_xtime14"`
	ChainXtime15     string      `json:"chain_xtime15"`
	ChainXtime16     string      `json:"chain_xtime16"`
	// s7
	Baud      int     `json:"baud"`
	AsicCount int     `json:"asic_count"`
	Timeout   int     `json:"timeout"`
	Voltage   float32 `json:"voltage,string"`
	USBPipe   int     `json:"USB Pipe,string"`
	HWv1      int     `json:"hwv1"`
	HWv2      int     `json:"hwv2"`
	HWv3      int     `json:"hwv3"`
	HWv4      int     `json:"hwv4"`
	TempAvg   int16   `json:"temp_avg"`
}

GenericStats - generic antminer stats struct

func (*GenericStats) D3

func (s *GenericStats) D3() (*StatsD3, error)

D3 - get struct fields only related to D3

func (*GenericStats) L3

func (s *GenericStats) L3() (*StatsL3, error)

L3 - get struct fields only related to L3+

func (*GenericStats) S7

func (s *GenericStats) S7() (*StatsS7, error)

S7 - get struct fields only related to S7

func (*GenericStats) S9

func (s *GenericStats) S9() (*StatsS9, error)

S9 - get struct fields only related to S9

func (*GenericStats) T9

func (s *GenericStats) T9() (*StatsT9, error)

T9 - get struct fields only related to T9+

type Pool

type Pool struct {
	Accepted            int64
	BestShare           int64   `json:"Best Share"`
	Diff1Shares         int64   `json:"Diff1 Shares"`
	DifficultyAccepted  float64 `json:"Difficulty Accepted"`
	DifficultyRejected  float64 `json:"Difficulty Rejected"`
	DifficultyStale     float64 `json:"Difficulty Stale"`
	Discarded           int64
	GetFailures         int64 `json:"Get Failures"`
	Getworks            int64
	HasGBT              bool    `json:"Has GBT"`
	HasStratum          bool    `json:"Has Stratum"`
	LastShareDifficulty float64 `json:"Last Share Difficulty"`
	LastShareTime       string  `json:"Last Share Time"`
	LongPoll            string  `json:"Long Poll"`
	Pool                int64   `json:"POOL"`
	PoolRejectedPercent float64 `json:"Pool Rejected%"`
	PoolStalePercent    float64 `json:"Pool Stale%"`
	Priority            int64
	ProxyType           string `json:"Proxy Type"`
	Proxy               string
	Quota               int64
	Rejected            int64
	RemoteFailures      int64 `json:"Remote Failures"`
	Stale               int64
	Status              string
	StratumActive       bool   `json:"Stratum Active"`
	StratumURL          string `json:"Stratum URL"`
	URL                 string `json:"URL"`
	User                string `json:"User"`
	Works               int64
}

Pool - get working pools

type Stats

type Stats interface {
	S7() (*StatsS7, error)
	S9() (*StatsS9, error)
	D3() (*StatsD3, error)
	L3() (*StatsL3, error)
	T9() (*StatsT9, error)
}

Stats is a generic stats interface, returned by method Stats()

type StatsD3

type StatsD3 struct {
	Stats                 int    `json:"STATS"`
	CGMiner               string `json:"CGMiner,omitempty"`
	Miner                 string
	CompileTime           string
	Type                  string
	ID                    string
	Elapsed               int64 `json:"Elapsed"`
	Calls                 int
	Wait                  float64
	Min                   float64
	Max                   float64
	Ghs5s                 float64 `json:"GHS 5s,string"`
	GhsAverage            float64 `json:"GHS av"`
	MinerCount            int16   `json:"miner_count"`
	Frequency             float32 `json:"frequency,string"`
	FanNum                int16   `json:"fan_num"`
	Fan1                  int16   `json:"fan1"`
	Fan2                  int16   `json:"fan2"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	NotMatchingWork       int     `json:"no_matching_work"`
	TempNum               int16   `json:"temp_num"`
	Temp1                 int16   `json:"temp1"`
	Temp2                 int16   `json:"temp2"`
	Temp3                 int16   `json:"temp3"`
	Temp4                 int16   `json:"temp4"`
	Temp2_1               int16   `json:"temp2_1"`
	Temp2_2               int16   `json:"temp2_2"`
	Temp2_3               int16   `json:"temp2_3"`
	TempMax               int16   `json:"temp_max"`
	ChainAcn1             int     `json:"chain_acn1"`
	ChainAcn2             int     `json:"chain_acn2"`
	ChainAcn3             int     `json:"chain_acn3"`
	ChainAcs1             string  `json:"chain_acs1"`
	ChainAcs2             string  `json:"chain_acs2"`
	ChainAcs3             string  `json:"chain_acs3"`
	ChainHW1              int     `json:"chain_hw1"`
	ChainHW2              int     `json:"chain_hw2"`
	ChainHW3              int     `json:"chain_hw3"`
	ChainRate1            float32 `json:"chain_rate1"`
	ChainRate2            float32 `json:"chain_rate2"`
	ChainRate3            float32 `json:"chain_rate3"`
}

StatsD3 - antminer stats related to D3

type StatsL3

type StatsL3 struct {
	CGMiner               string
	Miner                 string
	CompileTime           string
	Type                  string
	MinerCount            int16 `json:"miner_count"`
	Elapsed               int64 `json:"Elapsed"`
	Wait                  float64
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	NotMatchingWork       int     `json:"no_matching_work"`
	Stats                 int     `json:"STATS"`
	Min                   float64
	Max                   float64
	ID                    string
	Calls                 int
	Frequency             float32 `json:"frequency,string"`
	FanNum                int16   `json:"fan_num"`
	Fan1                  int16   `json:"fan1"`
	Fan2                  int16   `json:"fan2"`
	TempMax               int16   `json:"temp_max"`
	TempNum               int16   `json:"temp_num"`
	Temp1                 int16   `json:"temp1"`
	Temp2                 int16   `json:"temp2"`
	Temp3                 int16   `json:"temp3"`
	Temp4                 int16   `json:"temp4"`
	Temp2_1               int16   `json:"temp2_1"`
	Temp2_2               int16   `json:"temp2_2"`
	Temp2_3               int16   `json:"temp2_3"`
	Temp2_4               int16   `json:"temp2_4"`
	Temp3_1               int16   `json:"temp31"`
	Temp3_2               int16   `json:"temp32"`
	Temp3_3               int16   `json:"temp33"`
	Temp3_4               int16   `json:"temp34"`
	Temp4_1               int16   `json:"temp4_1"`
	Temp4_2               int16   `json:"temp4_2"`
	Temp4_3               int16   `json:"temp4_3"`
	Temp4_4               int16   `json:"temp4_4"`
	Ghs5s                 float64 `json:"GHS 5s,string"`
	GhsAverage            float64 `json:"GHS av"`
	ChainHW1              int     `json:"chain_hw1"`
	ChainHW2              int     `json:"chain_hw2"`
	ChainHW3              int     `json:"chain_hw3"`
	ChainHW4              int     `json:"chain_hw4"`
	ChainAcs1             string  `json:"chain_acs1"`
	ChainAcs2             string  `json:"chain_acs2"`
	ChainAcs3             string  `json:"chain_acs3"`
	ChainAcs4             string  `json:"chain_acs4"`
	ChainAcn1             int     `json:"chain_acn1"`
	ChainAcn2             int     `json:"chain_acn2"`
	ChainAcn3             int     `json:"chain_acn3"`
	ChainAcn4             int     `json:"chain_acn4"`
	ChainRate1            float32 `json:"chain_rate1"`
	ChainRate2            float32 `json:"chain_rate2"`
	ChainRate3            float32 `json:"chain_rate3"`
	ChainRate4            float32 `json:"chain_rate4"`
}

StatsL3 - antminer stats related to L3+

type StatsS7

type StatsS7 struct {
	CGMiner               string `json:"CGMiner,omitempty"`
	Miner                 string
	CompileTime           string
	Type                  string
	Stats                 int `json:"STATS"`
	ID                    string
	Elapsed               int64 `json:"Elapsed"`
	Calls                 int
	Wait                  float64
	Max                   float64
	Min                   float64
	Ghs5s                 float64 `json:"GHS 5s"`
	GhsAverage            float64 `json:"GHS av"`
	Baud                  int     `json:"baud"`
	MinerCount            int16   `json:"miner_count"`
	AsicCount             int     `json:"asic_count"`
	Timeout               int     `json:"timeout"`
	Frequency             float32 `json:"frequency,string"`
	Voltage               float32 `json:"voltage,string"`
	FanNum                int16   `json:"fan_num"`
	Fan1                  int16   `json:"fan1"`
	Fan3                  int16   `json:"fan3"`
	TempNum               int16   `json:"temp_num"`
	Temp1                 int16   `json:"temp1"`
	Temp2                 int16   `json:"temp2"`
	Temp3                 int16   `json:"temp3"`
	TempAvg               int16   `json:"temp_avg"`
	TempMax               int16   `json:"temp_max"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	NotMatchingWork       int     `json:"no_matching_work"`
	USBPipe               int     `json:"USB Pipe,string"`
	HWv1                  int     `json:"hwv1"`
	HWv2                  int     `json:"hwv2"`
	HWv3                  int     `json:"hwv3"`
	HWv4                  int     `json:"hwv4"`
	ChainAcn1             int     `json:"chain_acn1"`
	ChainAcn2             int     `json:"chain_acn2"`
	ChainAcn3             int     `json:"chain_acn3"`
	ChainAcs1             string  `json:"chain_acs1"`
	ChainAcs2             string  `json:"chain_acs2"`
	ChainAcs3             string  `json:"chain_acs3"`
}

StatsS7 - generic antminer stats struct

type StatsS9

type StatsS9 struct {
	BMMiner               string
	API                   string
	Miner                 string
	CompileTime           string
	Type                  string
	MinerID               string `json:"miner_id"`
	MinerVersion          string `json:"miner_version"`
	MinerCount            int16  `json:"miner_count"`
	Elapsed               int64  `json:"Elapsed"`
	Wait                  float64
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	Stats                 int     `json:"STATS"`
	Max                   float64
	NotMatchingWork       int `json:"no_matching_work"`
	ID                    string
	Calls                 int
	Min                   float64
	TotalAcn              int16   `json:"total_acn"`
	TotalRate             float32 `json:"total_rate"`
	TotalRateIdeal        float32 `json:"total_rateideal"`
	TotalFrequencyAvg     float32 `json:"total_freqavg"`
	Frequency             float32 `json:"frequency,string"`
	FrequencyAvg6         float32 `json:"freq_avg6"`
	FrequencyAvg7         float32 `json:"freq_avg7"`
	FrequencyAvg8         float32 `json:"freq_avg8"`
	FanNum                int16   `json:"fan_num"`
	Fan3                  int16   `json:"fan3"`
	Fan6                  int16   `json:"fan6"`
	TempMax               int16   `json:"temp_max"`
	TempNum               int16   `json:"temp_num"`
	Temp6                 int16   `json:"temp6"`
	Temp7                 int16   `json:"temp7"`
	Temp8                 int16   `json:"temp8"`
	Temp2_6               int16   `json:"temp2_6"`
	Temp2_7               int16   `json:"temp2_7"`
	Temp2_8               int16   `json:"temp2_8"`
	Ghs5s                 float64 `json:"GHS 5s,string"`
	GhsAverage            float64 `json:"GHS av"`
	ChainHW6              int     `json:"chain_hw6"`
	ChainHW7              int     `json:"chain_hw7"`
	ChainHW8              int     `json:"chain_hw8"`
	ChainAcs6             string  `json:"chain_acs6"`
	ChainAcs7             string  `json:"chain_acs7"`
	ChainAcs8             string  `json:"chain_acs8"`
	ChainAcn6             int     `json:"chain_acn6"`
	ChainAcn7             int     `json:"chain_acn7"`
	ChainAcn8             int     `json:"chain_acn8"`
	ChainRate6            float32 `json:"chain_rate6"`
	ChainRate7            float32 `json:"chain_rate7"`
	ChainRate8            float32 `json:"chain_rate8"`
	ChainRateIdeal6       float32 `json:"chain_rateideal6"`
	ChainRateIdeal7       float32 `json:"chain_rateideal7"`
	ChainRateIdeal8       float32 `json:"chain_rateideal8"`
	ChainOpenCore6        int     `json:"chain_opencore_6,string"`
	ChainOpenCore7        int     `json:"chain_opencore_7,string"`
	ChainOpenCore8        int     `json:"chain_opencore_8,string"`
	ChainOffside6         int     `json:"chain_offside_6,string"`
	ChainOffside7         int     `json:"chain_offside_7,string"`
	ChainOffside8         int     `json:"chain_offside_8,string"`
	// ChainXtime6 need to be parsed?
	ChainXtime6 string `json:"chain_xtime6"`
	ChainXtime7 string `json:"chain_xtime7"`
	ChainXtime8 string `json:"chain_xtime8"`
}

StatsS9 - get stats from antminer S9

type StatsT9

type StatsT9 struct {
	BMMiner               string
	Miner                 string
	CompileTime           string
	Type                  string
	ID                    string
	Stats                 int   `json:"STATS"`
	Elapsed               int64 `json:"Elapsed"`
	Calls                 int
	Wait                  float64
	Max                   float64
	Min                   float64
	Ghs5s                 float64 `json:"GHS 5s,string"`
	GhsAverage            float64 `json:"GHS av"`
	MinerCount            int16   `json:"miner_count"`
	Frequency             float32 `json:"frequency,string"`
	FanNum                int16   `json:"fan_num"`
	Fan3                  int16   `json:"fan3"`
	Fan6                  int16   `json:"fan6"`
	TempNum               int16   `json:"temp_num"`
	Temp2                 int16   `json:"temp2"`
	Temp3                 int16   `json:"temp3"`
	Temp4                 int16   `json:"temp4"`
	Temp9                 int16   `json:"temp9"`
	Temp10                int16   `json:"temp10"`
	Temp11                int16   `json:"temp11"`
	Temp12                int16   `json:"temp12"`
	Temp13                int16   `json:"temp13"`
	Temp14                int16   `json:"temp14"`
	Temp2_2               int16   `json:"temp2_2"`
	Temp2_3               int16   `json:"temp2_3"`
	Temp2_4               int16   `json:"temp2_4"`
	Temp2_9               int16   `json:"temp2_9"`
	Temp2_10              int16   `json:"temp2_10"`
	Temp2_11              int16   `json:"temp2_11"`
	Temp2_12              int16   `json:"temp2_12"`
	Temp2_13              int16   `json:"temp2_13"`
	Temp2_14              int16   `json:"temp2_14"`
	TempMax               int16   `json:"temp_max"`
	FrequencyAvg2         float32 `json:"freq_avg2"`
	FrequencyAvg3         float32 `json:"freq_avg3"`
	FrequencyAvg4         float32 `json:"freq_avg4"`
	FrequencyAvg5         float32 `json:"freq_avg5"`
	FrequencyAvg6         float32 `json:"freq_avg6"`
	FrequencyAvg7         float32 `json:"freq_avg7"`
	FrequencyAvg8         float32 `json:"freq_avg8"`
	FrequencyAvg9         float32 `json:"freq_avg9"`
	FrequencyAvg10        float32 `json:"freq_avg10"`
	FrequencyAvg11        float32 `json:"freq_avg11"`
	FrequencyAvg12        float32 `json:"freq_avg12"`
	FrequencyAvg13        float32 `json:"freq_avg13"`
	FrequencyAvg14        float32 `json:"freq_avg14"`
	TotalRateIdeal        float32 `json:"total_rateideal"`
	TotalFrequencyAvg     float32 `json:"total_freqavg"`
	TotalAcn              int16   `json:"total_acn"`
	TotalRate             float32 `json:"total_rate"`
	ChainRateIdeal2       float32 `json:"chain_rateideal2"`
	ChainRateIdeal3       float32 `json:"chain_rateideal3"`
	ChainRateIdeal4       float32 `json:"chain_rateideal4"`
	ChainRateIdeal9       float32 `json:"chain_rateideal9"`
	ChainRateIdeal10      float32 `json:"chain_rateideal10"`
	ChainRateIdeal11      float32 `json:"chain_rateideal11"`
	ChainRateIdeal12      float32 `json:"chain_rateideal12"`
	ChainRateIdeal13      float32 `json:"chain_rateideal13"`
	ChainRateIdeal14      float32 `json:"chain_rateideal14"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	NotMatchingWork       int     `json:"no_matching_work"`
	ChainAcn2             int     `json:"chain_acn2"`
	ChainAcn3             int     `json:"chain_acn3"`
	ChainAcn4             int     `json:"chain_acn4"`
	ChainAcn9             int     `json:"chain_acn9"`
	ChainAcn10            int     `json:"chain_acn10"`
	ChainAcn11            int     `json:"chain_acn11"`
	ChainAcn12            int     `json:"chain_acn12"`
	ChainAcn13            int     `json:"chain_acn13"`
	ChainAcn14            int     `json:"chain_acn14"`
	ChainAcs2             string  `json:"chain_acs2"`
	ChainAcs3             string  `json:"chain_acs3"`
	ChainAcs4             string  `json:"chain_acs4"`
	ChainAcs9             string  `json:"chain_acs9"`
	ChainAcs10            string  `json:"chain_acs10"`
	ChainAcs11            string  `json:"chain_acs11"`
	ChainAcs12            string  `json:"chain_acs12"`
	ChainAcs13            string  `json:"chain_acs13"`
	ChainAcs14            string  `json:"chain_acs14"`
	ChainHW2              int     `json:"chain_hw2"`
	ChainHW3              int     `json:"chain_hw3"`
	ChainHW4              int     `json:"chain_hw4"`
	ChainHW9              int     `json:"chain_hw9"`
	ChainHW10             int     `json:"chain_hw10"`
	ChainHW11             int     `json:"chain_hw11"`
	ChainHW12             int     `json:"chain_hw12"`
	ChainHW13             int     `json:"chain_hw13"`
	ChainHW14             int     `json:"chain_hw14"`
	ChainRate2            float32 `json:"chain_rate2"`
	ChainRate3            float32 `json:"chain_rate3"`
	ChainRate4            float32 `json:"chain_rate4"`
	ChainRate9            float32 `json:"chain_rate9"`
	ChainRate10           float32 `json:"chain_rate10"`
	ChainRate11           float32 `json:"chain_rate11"`
	ChainRate12           float32 `json:"chain_rate12"`
	ChainRate13           float32 `json:"chain_rate13"`
	ChainRate14           float32 `json:"chain_rate14"`
	ChainXtime2           string  `json:"chain_xtime2"`
	ChainXtime3           string  `json:"chain_xtime3"`
	ChainXtime4           string  `json:"chain_xtime4"`
	ChainXtime9           string  `json:"chain_xtime9"`
	ChainXtime10          string  `json:"chain_xtime10"`
	ChainXtime11          string  `json:"chain_xtime11"`
	ChainXtime12          string  `json:"chain_xtime12"`
	ChainXtime13          string  `json:"chain_xtime13"`
	ChainXtime14          string  `json:"chain_xtime14"`
	ChainOffside2         int     `json:"chain_offside_2,string"`
	ChainOffside3         int     `json:"chain_offside_3,string"`
	ChainOffside4         int     `json:"chain_offside_4,string"`
	ChainOffside9         int     `json:"chain_offside_9,string"`
	ChainOffside10        int     `json:"chain_offside_10,string"`
	ChainOffside11        int     `json:"chain_offside_11,string"`
	ChainOffside12        int     `json:"chain_offside_12,string"`
	ChainOffside13        int     `json:"chain_offside_13,string"`
	ChainOffside14        int     `json:"chain_offside_14,string"`
	ChainOpenCore2        int     `json:"chain_opencore_2,string"`
	ChainOpenCore3        int     `json:"chain_opencore_3,string"`
	ChainOpenCore4        int     `json:"chain_opencore_4,string"`
	ChainOpenCore9        int     `json:"chain_opencore_9,string"`
	ChainOpenCore10       int     `json:"chain_opencore_10,string"`
	ChainOpenCore11       int     `json:"chain_opencore_11,string"`
	ChainOpenCore12       int     `json:"chain_opencore_12,string"`
	ChainOpenCore13       int     `json:"chain_opencore_13,string"`
	ChainOpenCore14       int     `json:"chain_opencore_14,string"`
	MinerID               string  `json:"miner_id"`
	MinerVersion          string  `json:"miner_version"`
}

StatsT9 - generic antminer stats struct

type Status

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

Status - status of request

type Summary

type Summary struct {
	Accepted              int64
	BestShare             int64   `json:"Best Share"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	DeviceRejectedPercent float64 `json:"Device Rejected%"`
	DifficultyAccepted    float64 `json:"Difficulty Accepted"`
	DifficultyRejected    float64 `json:"Difficulty Rejected"`
	DifficultyStale       float64 `json:"Difficulty Stale"`
	Discarded             int64
	Elapsed               int64
	FoundBlocks           int64 `json:"Found Blocks"`
	GetFailures           int64 `json:"Get Failures"`
	Getworks              int64
	HardwareErrors        int64 `json:"Hardware Errors"`
	LocalWork             int64 `json:"Local Work"`
	// non s7/s9/d3 etc.
	MHS5s float64 `json:"MHS 5s"`
	MHSav float64 `json:"MHS av"`
	// s7 and later
	GHS5s               float64 `json:"GHS 5s,string"`
	GHSav               float64 `json:"GHS av"`
	NetworkBlocks       int64   `json:"Network Blocks"`
	PoolRejectedPercent float64 `json:"Pool Rejected%"`
	PoolStalePercent    float64 `json:"Pool Stale%"`
	Rejected            int64
	RemoteFailures      int64 `json:"Remote Failures"`
	Stale               int64
	TotalMH             float64 `json:"Total MH"`
	Utility             float64
	WorkUtility         float64 `json:"Work Utility"`
	LastGetWork         int     `json:"Last getwork"`
}

Summary - miner summary

type Version

type Version struct {
	BMMiner     string
	API         string
	Miner       string
	CompileTime string
	Type        string
}

Version - version of miner software and hw model

type VersionResponse

type VersionResponse struct {
	GenericResponse
	Version []Version `json:"VERSION"`
}

VersionResponse - returned by "version" command

Source Files

  • api.go
  • cgminer.go
  • interfaces.go
  • stats.go
  • types.go

Jump to

Keyboard shortcuts

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