Documentation ¶
Overview ¶
Package miner implements various Bloc-compatible miners that can be used by the GUI
Index ¶
- Variables
- func DetermineMinerType(dir string) (string, string, error)
- func HumanizeHashrate(hashrate float64) string
- func HumanizeTime(seconds int) string
- type Base
- type Config
- type Miner
- type ProcessingConfig
- type Stats
- type XmrStak
- func (miner *XmrStak) GetLastHashrate() float64
- func (miner *XmrStak) GetName() string
- func (miner *XmrStak) GetProcessingConfig() ProcessingConfig
- func (miner *XmrStak) GetStats() (Stats, error)
- func (miner *XmrStak) WriteConfig(poolEndpoint string, walletAddress string, coinAlgorithm string, ...) error
- type XmrStakResponse
- type Xmrig
- type XmrigAPIConfig
- type XmrigConfig
- type XmrigCpuConfig
- type XmrigHttpConfig
- type XmrigPoolConfig
- type XmrigRandomXConfig
- type XmrigResponse
Constants ¶
This section is empty.
Variables ¶
var SupportedMiners = []string{"xmr-stak", "xmrig"}
SupportedMiners contains a list of the currently supported miners
Functions ¶
func DetermineMinerType ¶
DetermineMinerType checks the given path for supported miners and returns the type of miner and path to the executable
func HumanizeHashrate ¶
HumanizeHashrate returns the H/s, KH/s or MH/s representation of hashrate
func HumanizeTime ¶
HumanizeTime turns seconds into minutes, hours, etc
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base implements core functionality common to all miners
type Config ¶
type Config struct { // Type of miner Type string `json:"type"` // Path to the selected miner's executable Path string `json:"path"` // Endpoint of the miner's JSON API Endpoint string `json:"endpoint"` // The type of hardware used for mining (1 = computer with CPU only, 2 = computer with GPU) HardwareType uint8 `json:"hardware_type"` }
Config holds miner specific configuration information
type Miner ¶
type Miner interface { // Start the miner Start() error // Stop the miner Stop() error // WriteConfig writes the miner's configuration to the file format as // specified by the miner WriteConfig( poolEndpoint string, walletAddress string, coinAlgorithm string, XmrigAlgo string, XmrigVariant string, processingConfig ProcessingConfig) error // GetProcessingConfig returns the current miner processing config // TODO: Currently only CPU threads, extend this to full CPU/GPU config GetProcessingConfig() ProcessingConfig // GetName returns the name of the miner GetName() string // GetLastHashrate returns the last reported hashrate GetLastHashrate() float64 // GetStats returns the current miner stats GetStats() (Stats, error) }
Miner defines the required behaviour to be implemented by a miner to work with the GUI
func CreateMiner ¶
CreateMiner creates a supported miner from the given configuration
type ProcessingConfig ¶
type ProcessingConfig struct { // Type of miner Type string `json:"type"` // Threads is the amount of CPU threads Threads uint16 `json:"threads"` // Threads is the amount of CPU threads ThreadsContent []uint16 `json:"threads_content"` // MaxThreads is the maximum threads as read by runtime.NumCPU MaxThreads uint16 `json:"max_threads"` // MaxUsage is the maximum CPU usage in percentage the miner should // attempt to use. // Currently only supported by xmrig CPU backend MaxUsage uint8 `json:"max_usage"` // The type of hardware used for mining (1 = computer with CPU only, 2 = computer with GPU) HardwareType uint8 `json:"hardware_type"` }
ProcessingConfig holds the config for the miner's processing setup TODO: Right now this is only for CPU threads and will be extended into full CPU/GPU config
type Stats ¶
type Stats struct { // Hashrate is the current miner hashrate Hashrate float64 `json:"hashrate"` // HashrateHuman is the H/s, KH/s or MH/s representation of hashrate HashrateHuman string `json:"hashrate_human"` // CurrentDifficulty as set by the pool CurrentDifficulty int64 `json:"current_difficulty"` SharesGood int `json:"shares_good"` SharesBad int `json:"shares_bad"` // Uptime for the miner in seconds Uptime int `json:"uptime"` // UptimeHuman is the human readable version of uptime, ex. 10 minutes UptimeHuman string `json:"uptime_human"` // Errors is a list of errors that have occurred Errors []string `json:"errors"` // UpdateGraph is set to true if the stats graph should be updated UpdateGraph bool `json:"update_graph"` // Address contains the Bloc address we are mining to // TODO: This should be somewhere else, it's not stats! Address string `json:"address"` }
Stats contains the miner statistics required by the front-end
type XmrStak ¶
type XmrStak struct { Base // contains filtered or unexported fields }
XmrStak implements the miner interface for the xmr-stak miner https://github.com/fireice-uk/xmr-stak
func NewXmrStak ¶
NewXmrStak creates a new xmr-stak miner instance
func (*XmrStak) GetLastHashrate ¶
GetLastHashrate returns the last reported hashrate
func (*XmrStak) GetProcessingConfig ¶
func (miner *XmrStak) GetProcessingConfig() ProcessingConfig
GetProcessingConfig returns the current miner processing config TODO: Currently only CPU threads, extend this to full CPU/GPU config
func (*XmrStak) WriteConfig ¶
func (miner *XmrStak) WriteConfig( poolEndpoint string, walletAddress string, coinAlgorithm string, XmrigAlgo string, XmrigVariant string, processingConfig ProcessingConfig) error
WriteConfig writes the miner's configuration in the xmr-stak format
type XmrStakResponse ¶
type XmrStakResponse struct { Version string `json:"version"` Hashrate struct { Threads [][]interface{} `json:"threads"` Total []float64 `json:"total"` Highest float64 `json:"highest"` } `json:"hashrate"` Results struct { DiffCurrent int64 `json:"diff_current"` SharesGood int `json:"shares_good"` SharesTotal int `json:"shares_total"` AvgTime float64 `json:"avg_time"` HashesTotal int `json:"hashes_total"` Best []int `json:"best"` ErrorLog []struct { Count int `json:"count"` LastSeen int `json:"last_seen"` Text string `json:"text"` } `json:"error_log"` } `json:"results"` Connection struct { Pool string `json:"pool"` Uptime int `json:"uptime"` Ping int `json:"ping"` ErrorLog []struct { LastSeen int `json:"last_seen"` Text string `json:"text"` } `json:"error_log"` } `json:"connection"` }
XmrStakResponse contains the data from xmr-stak API Generated with https://mholt.github.io/json-to-go/
type Xmrig ¶
type Xmrig struct { Base // contains filtered or unexported fields }
Xmrig implements the miner interface for the xmrig miner, including xmrig-amd and xmrig-nvidia https://github.com/xmrig/xmrig https://github.com/xmrig/xmrig-amd https://github.com/xmrig/xmrig-nvidia
func (*Xmrig) GetLastHashrate ¶
GetLastHashrate returns the last reported hashrate
func (*Xmrig) GetProcessingConfig ¶
func (miner *Xmrig) GetProcessingConfig() ProcessingConfig
GetProcessingConfig returns the current miner processing config TODO: Currently only CPU threads, extend this to full CPU/GPU config
func (*Xmrig) WriteConfig ¶
func (miner *Xmrig) WriteConfig( poolEndpoint string, walletAddress string, coinAlgorithm string, XmrigAlgo string, XmrigVariant string, processingConfig ProcessingConfig) error
WriteConfig writes the miner's configuration in the xmrig format
type XmrigAPIConfig ¶
type XmrigAPIConfig struct { Id interface{} `json:"id"` WorkerID interface{} `json:"worker-id"` }
XmrigAPIConfig contains the Xmrig API config
type XmrigConfig ¶
type XmrigConfig struct { API XmrigAPIConfig `json:"api"` HTTP XmrigHttpConfig `json:"http"` Autosave bool `json:"autosave"` Version int `json:"version"` Background bool `json:"background"` Colors bool `json:"colors"` RandomX XmrigRandomXConfig `json:"randomx"` Cpu XmrigCpuConfig `json:"cpu"` DonateLevel int `json:"donate-level"` DonateOverProxy int `json:"donate-over-proxy"` LogFile interface{} `json:"log-file"` Pools []XmrigPoolConfig `json:"pools"` PrintTime int `json:"print-time"` Retries int `json:"retries"` RetryPause int `json:"retry-pause"` Syslog bool `json:"syslog"` UserAgent interface{} `json:"user-agent"` Watch bool `json:"watch"` }
XmrigConfig is the config.json structure for Xmrig Generated with https://mholt.github.io/json-to-go/
type XmrigCpuConfig ¶ added in v1.1.1
type XmrigCpuConfig struct { Enabled bool `json:"enabled"` HugePages bool `json:"huge-pages"` HwAes interface{} `json:"hw-aes"` Priority interface{} `json:"priority"` Asm bool `json:"asm"` Argon2Impl interface{} `json:"argon2-impl"` Argon2 []int `json:"argon2"` Cn [][]int `json:"cn"` CnHeavy [][]int `json:"cn-heavy"` CnLite [][]int `json:"cn-lite"` CnPico [][]int `json:"cn-pico"` CnGpu []int `json:"cn/gpu"` Rx []int `json:"rx"` RxWow []int `json:"rx/wow"` Cn0 bool `json:"cn/0"` CnLite0 bool `json:"cn-lite/0"` }
XmrigCpuConfig contains the Xmrig CPU config
type XmrigHttpConfig ¶ added in v1.1.1
type XmrigHttpConfig struct { Enabled bool `json:"enabled"` Host string `json:"host"` Port int `json:"port"` AccessToken interface{} `json:"access-token"` Restricted bool `json:"restricted"` }
XmrigHttpConfig contains the Xmrig HTTP config
type XmrigPoolConfig ¶
type XmrigPoolConfig struct { // Algo interface{} `json:"algo"` Algo string `json:"algo"` URL string `json:"url"` User string `json:"user"` Pass string `json:"pass"` RigId string `json:"rig-id"` Nicehash bool `json:"nicehash"` Keepalive bool `json:"keepalive"` Enabled bool `json:"enabled"` Tls bool `json:"tls"` TlsFingerprint interface{} `json:"tls-fingerprint"` Daemon bool `json:"daemon"` }
XmrigPoolConfig contains the configuration for a pool in Xmrig
type XmrigRandomXConfig ¶ added in v1.1.1
XmrigRandomXConfig contains the Xmrig RandomX config
type XmrigResponse ¶
type XmrigResponse struct { ID string `json:"id"` WorkerID string `json:"worker_id"` Uptime int `json:"uptime"` Features []string `json:"features"` Results struct { DiffCurrent int64 `json:"diff_current"` SharesGood int `json:"shares_good"` SharesTotal int `json:"shares_total"` AvgTime int `json:"avg_time"` HashesTotal int `json:"hashes_total"` Best []int `json:"best"` ErrorLog []string `json:"error_log"` } `json:"results"` Algo string `json:"algo"` Connection struct { Pool string `json:"pool"` Ip string `json:"ip"` Uptime int `json:"uptime"` Ping int `json:"ping"` Failures int `json:"failures"` Tls interface{} `json:"tls"` TlsFingerprint interface{} `json:"tls-fingerprint"` ErrorLog []string `json:"error_log"` } `json:"connection"` Version string `json:"version"` Kind string `json:"kind"` Ua string `json:"ua"` CPU struct { Brand string `json:"brand"` Aes bool `json:"aes"` Avx2 bool `json:"avx2"` X64 bool `json:"x64"` L2 int `json:"l2"` L3 int `json:"l3"` Cores int `json:"cores"` Threads int `json:"threads"` Packages int `json:"packages"` Nodes int `json:"nodes"` Backend string `json:"backend"` Assembly string `json:"assembly"` } `json:"cpu"` Hugepages bool `json:"hugepages"` DonateLevel int `json:"donate_level"` Hashrate struct { Total []float64 `json:"total"` Highest float64 `json:"highest"` Threads [][]float64 `json:"threads"` } `json:"hashrate"` }
XmrigResponse contains the data from xmrig API Generated with https://mholt.github.io/json-to-go/