cgminer

package module
v0.0.0-...-a1904c4 Latest Latest
Warning

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

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

README

CGMiner API for Go

Installation

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

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

API Documentation

Full godoc output from the latest code in master is available here:

http://godoc.org/github.com/Nitron/go-cgminer-api

Quickstart

package main

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

func main() {
    miner := cgminer.New("localhost", 4028)
    summary, err := miner.Summary()
    if err != nil {
        log.Fatalln("Unable to connect to CGMiner: ", err)
    }

    // Convert hashrate into KH/s
    hashrate := summary.MHSav * 1000.0

    log.Printf("Average Hashrate: %f KH/s\n", hashrate)
}

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
}

func New

func New(hostname string, port int64) *CGMiner

New 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 NewDebug

func NewDebug(hostname string, port int64, debug bool) *CGMiner

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) 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

type Devs

type Devs struct {
	ID                  int64
	Name                string
	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
	KHSav               float64 `json:"KHS av"`
	KHS5s               float64 `json:"KHS 5s"`
	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"`
	Frequency           float64 `json:"Frequency"`
	Diff1Work           float64 `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"`
}

type Pool

type Pool struct {
	Accepted               int64
	BestShare              float64 `json:"Best Share"`
	Diff1Shares            float64 `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          int64   `json:"Last Share Time"`
	LongPoll               string  `json:"Long Poll"`
	Pool                   int64   `json:"POOL"`
	PoolRejectedPercentage float64 `json:"Pool Rejected%"`
	PoolStalePercentage    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
	User                   string
	Works                  int64
}

type Summary

type Summary struct {
	Accepted               int64
	BestShare              float64 `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"`
	KHS5s                  float64 `json:"KHS 5s"`
	KHSav                  float64 `json:"KHS av"`
	MHS5s                  float64 `json:"MHS 5s"`
	MHSav                  float64 `json:"MHS av"`
	NetworkBlocks          int64   `json:"Network Blocks"`
	PoolRejectedPercentage float64 `json:"Pool Rejected%"`
	PoolStalePercentage    float64 `json:"Pool Stale%"`
	Rejected               int64
	RemoteFailures         int64 `json:"Remote Failures"`
	Stale                  int64
	TotalMH                float64 `json:"Total MH"`
	Utilty                 float64
	WorkUtility            float64 `json:"Work Utility"`
}

Jump to

Keyboard shortcuts

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