cgminer_client

package module
v0.0.0-...-74d91ee Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 7 Imported by: 2

README

Build Status

cgminer golang client

Just enough of the client to get some work done. PR's welcome.

Thanks to HyperBitShop.io for sponsoring this project.

Usage:

client := cgminer_client.New("10.0.0.1", 4028, 5)

Build

Install dep and the dependencies...

make dep make

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CgClient

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

func (*CgClient) ChipStat

func (miner *CgClient) ChipStat() (*[]ChipStat, error)

func (*CgClient) Devs

func (miner *CgClient) Devs() (*[]Dev, error)

Devs returns basic information on the miner.

func (*CgClient) Quit

func (miner *CgClient) Quit() error

func (*CgClient) Restart

func (miner *CgClient) Restart() error

func (*CgClient) Summary

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

Summary returns basic information on the miner.

type ChipStat

type ChipStat struct {
	DevCommon
	Accept MapInt64
}

*

"DEVS": [
  {
    "ASC": 0,
    "Name": "ttyS1",
    "ID": 1,
    "1_accept": 154,
    "2_accept": 132,
    "3_accept": 138,
    "4_accept": 129,

type ChipStatResponse

type ChipStatResponse struct {
	Status    []Status `json:"STATUS"`
	Data      []Map    `json:"DEVS"` // data goes into the map and then gets transformed into ChipStat
	Id        int64    `json:"id"`
	ChipStats []ChipStat
}

type Client

type Client interface {
	Devs() (*[]Dev, error)
	Quit() error
	Restart() error
	Summary() (*Summary, error)
	ChipStat() (*[]ChipStat, error)
}

func New

func New(hostname string, port int64, timeout time.Duration) Client

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

type Dev

type Dev struct {
	DevCommon
	Enabled               string  `json:"Enabled"`
	Status                string  `json:"Status"`
	Temperature           float64 `json:"temperature"`
	MHSav                 float64 `json:"MHS av"`
	MHS5s                 float64 `json:"MHS 5s"`
	MHS1m                 float64 `json:"MHS 1m"`
	MHS5m                 float64 `json:"MHS 5m"`
	MHS15m                float64 `json:"MHS 15m"`
	Accepted              int64   `json:"Accepted"`
	Rejected              int64   `json:"Rejected"`
	HardwareErrors        int64   `json:"Hardware Errors"`
	Utility               float64 `json:"Utility"`
	TotalMH               int64   `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"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	DeviceRejectedPercent float64 `json:"Device Rejected%"`
	DeviceElapsed         int64   `json:"Device Elapsed"`
}

type DevCommon

type DevCommon struct {
	Name string `json:"Name,omit"` // omit is special for prometheus_helper library to exclude it
	ASC  int    `json:"ASC"`
	ID   int    `json:"ID"`
}

type DevsResponse

type DevsResponse struct {
	Status []Status `json:"STATUS"`
	Devs   []Dev    `json:"DEVS"`
	Id     int64    `json:"id"`
}

type Map

type Map map[string]interface{}

type MapInt64

type MapInt64 map[string]int64

type Status

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

*

"STATUS": [
  {
    "STATUS": "S",
    "When": 1517894216,
    "Code": 9,
    "Msg": "4 ASC(s)",
    "Description": "cgminer 4.10.0"
  }
],

type Summary

type Summary struct {
	Elapsed               int64   `json:"Elapsed"`
	MHSav                 float64 `json:"MHS av"`
	MHS5s                 float64 `json:"MHS 5s"`
	MHS1m                 float64 `json:"MHS 1m"`
	MHS5m                 float64 `json:"MHS 5m"`
	MHS15m                float64 `json:"MHS 15m"`
	Temper1               float64 `json:"temper1"`
	Temper2               float64 `json:"temper2"`
	Temper3               float64 `json:"temper3"`
	Temper4               float64 `json:"temper4"`
	FoundBlocks           int64   `json:"Found Blocks"`
	Getworks              int64   `json:"Getworks"`
	Accepted              int64   `json:"Accepted"`
	Rejected              int64   `json:"Rejected"`
	HardwareErrors        int64   `json:"Hardware Errors"`
	Utility               float64 `json:"Utility"`
	Discarded             int64   `json:"Discarded"`
	Stale                 int64   `json:"Stale"`
	GetFailures           int64   `json:"Get Failures"`
	LocalWork             int64   `json:"Local Work"`
	RemoteFailures        int64   `json:"Remote Failures"`
	NetworkBlocks         int64   `json:"Network Blocks"`
	TotalMH               float64 `json:"Total MH"`
	WorkUtility           float64 `json:"Work Utility"`
	DifficultyAccepted    float64 `json:"Difficulty Accepted"`
	DifficultyRejected    float64 `json:"Difficulty Rejected"`
	DifficultyStale       float64 `json:"Difficulty Stale"`
	BestShare             int64   `json:"Best Share"`
	DeviceHardwarePercent float64 `json:"Device Hardware%"`
	DeviceRejectedPercent float64 `json:"Device Rejected%"`
	PoolRejectedPercent   float64 `json:"Pool Rejected%"`
	PoolStalePercent      float64 `json:"Pool Stale%"`
	LastGetwork           int64   `json:"Last getwork"`
	InputVolt1            float64 `json:"inputVolt1"`
	InputVolt2            float64 `json:"inputVolt2"`
	InputVolt3            float64 `json:"inputVolt3"`
	OutputVolt1           float64 `json:"outputVolt1"`
	OutputVolt2           float64 `json:"outputVolt2"`
	OutputVolt3           float64 `json:"outputVolt3"`
	InputCurrent1         float64 `json:"inputCurrent1"`
	InputCurrent2         float64 `json:"inputCurrent2"`
	InputCurrent3         float64 `json:"inputCurrent3"`
}

"Elapsed": 48417, "MHS av": 335.86, "MHS 5s": 357.15, "MHS 1m": 323.17, "MHS 5m": 357.15, "MHS 15m": 339.55, "temper1": 31, "temper2": 31, "temper3": 31, "temper4": 31, "Found Blocks": 0, "Getworks": 3236, "Accepted": 8215, "Rejected": 75, "Hardware Errors": 1654, "Utility": 10.18, "Discarded": 48716, "Stale": 0, "Get Failures": 0, "Local Work": 77113, "Remote Failures": 0, "Network Blocks": 366, "Total MH": 16261155, "Work Utility": 1.39, "Difficulty Accepted": 4538.375, "Difficulty Rejected": 42.875, "Difficulty Stale": 0, "Best Share": 8322, "Device Hardware%": 59.6036, "Device Rejected%": 3.8247, "Pool Rejected%": 0.9359, "Pool Stale%": 0, "Last getwork": 1517965137

type SummaryResponse

type SummaryResponse struct {
	Status  []Status  `json:"STATUS"`
	Summary []Summary `json:"SUMMARY"`
	Id      int64     `json:"id"`
}

Jump to

Keyboard shortcuts

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