func (miner *Xmrig) GetProcessingConfig() ProcessingConfig {
	configBytes, err := ioutil.ReadFile(
		filepath.Join(miner.Base.executablePath, "config.json"))
	if err != nil {
		return ProcessingConfig{}
	}
	if miner.isGPU {
		var config XmrigGPUConfig
		err = json.Unmarshal(configBytes, &config)
		if err != nil {
			return ProcessingConfig{}
		}
		return ProcessingConfig{
			MaxUsage:   config.MaxCPUUsage,
			Threads:    uint16(len(miner.resultStatsCache.Hashrate.Threads)),
			MaxThreads: uint16(runtime.NumCPU()),
			Type:       miner.name,
		}
	}
	var config XmrigConfig
	err = json.Unmarshal(configBytes, &config)
	if err != nil {
		return ProcessingConfig{}
	}
	return ProcessingConfig{
		MaxUsage:   config.MaxCPUUsage,
		Threads:    uint16(len(miner.resultStatsCache.Hashrate.Threads)),
		MaxThreads: uint16(runtime.NumCPU()),
		Type:       miner.name,
	}
}
GetProcessingConfig returns the current miner processing config
TODO: Currently only CPU threads, extend this to full CPU/GPU config
package miner
import (
	"encoding/json"
	"io/ioutil"
	"net/http"
	"path/filepath"
	"runtime"
	"strings"
)
type Xmrig struct {
	Base
	name             string
	endpoint         string
	lastHashrate     float64
	resultStatsCache XmrigResponse
	isGPU            bool
}
type XmrigConfig struct {
	Algo        string            `json:"algo"`
	Av          int               `json:"av"`
	Background  bool              `json:"background"`
	Colors      bool              `json:"colors"`
	CPUAffinity interface{}       `json:"cpu-affinity"`
	CPUPriority interface{}       `json:"cpu-priority"`
	DonateLevel int               `json:"donate-level"`
	LogFile     interface{}       `json:"log-file"`
	MaxCPUUsage uint8             `json:"max-cpu-usage"`
	PrintTime   int               `json:"print-time"`
	Retries     int               `json:"retries"`
	RetryPause  int               `json:"retry-pause"`
	Safe        bool              `json:"safe"`
	Syslog      bool              `json:"syslog"`
	Threads     uint16            `json:"threads"`
	Pools       []XmrigPoolConfig `json:"pools"`
	API         XmrigAPIConfig    `json:"api"`
}
type XmrigGPUConfig struct {
	Algo        string      `json:"algo"`
	Av          int         `json:"av"`
	Background  bool        `json:"background"`
	Colors      bool        `json:"colors"`
	CPUAffinity interface{} `json:"cpu-affinity"`
	CPUPriority interface{} `json:"cpu-priority"`
	DonateLevel int         `json:"donate-level"`
	LogFile     interface{} `json:"log-file"`
	MaxCPUUsage uint8       `json:"max-cpu-usage"`
	PrintTime   int         `json:"print-time"`
	Retries     int         `json:"retries"`
	RetryPause  int         `json:"retry-pause"`
	Safe        bool        `json:"safe"`
	Syslog      bool        `json:"syslog"`
	Threads []struct{}        `json:"threads"`
	Pools   []XmrigPoolConfig `json:"pools"`
	API     XmrigAPIConfig    `json:"api"`
}
type XmrigPoolConfig struct {
	URL       string `json:"url"`
	User      string `json:"user"`
	Pass      string `json:"pass"`
	Keepalive bool   `json:"keepalive"`
	Nicehash  bool   `json:"nicehash"`
	Variant   string `json:"variant"`
}
type XmrigAPIConfig struct {
	Port        int         `json:"port"`
	AccessToken interface{} `json:"access-token"`
	WorkerID    interface{} `json:"worker-id"`
}
type XmrigResponse struct {
	ID       string `json:"id"`
	WorkerID string `json:"worker_id"`
	Version  string `json:"version"`
	Kind     string `json:"kind"`
	Ua       string `json:"ua"`
	CPU      struct {
		Brand   string `json:"brand"`
		Aes     bool   `json:"aes"`
		X64     bool   `json:"x64"`
		Sockets int    `json:"sockets"`
	} `json:"cpu"`
	Algo        string `json:"algo"`
	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"`
	Results struct {
		DiffCurrent int      `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"`
	Connection struct {
		Pool     string   `json:"pool"`
		Uptime   int      `json:"uptime"`
		Ping     int      `json:"ping"`
		Failures int      `json:"failures"`
		ErrorLog []string `json:"error_log"`
	} `json:"connection"`
}
func NewXmrig(config Config) (*Xmrig, error) {
	endpoint := config.Endpoint
	if endpoint == "" {
		endpoint = "http://127.0.0.1:16000"
	}
	miner := Xmrig{
		name:     "xtcrig",
		endpoint: endpoint,
	}
	if (strings.Contains(config.Path, "nvidia") ||
		strings.Contains(config.Path, "amd")) &&
		strings.Contains(config.Path, "amd64") == false {
		miner.isGPU = true
		miner.name += "-gpu"
	}
	miner.Base.executableName = filepath.Base(config.Path)
	miner.Base.executablePath = filepath.Dir(config.Path)
	return &miner, nil
}
func (miner *Xmrig) WriteConfig(
	poolEndpoint string,
	walletAddress string,
	processingConfig ProcessingConfig) error {
	var err error
	var configBytes []byte
	if miner.isGPU {
		defaultConfig := miner.createGPUConfig(
			poolEndpoint,
			walletAddress)
		configBytes, err = json.Marshal(defaultConfig)
		if err != nil {
			return err
		}
	} else {
		defaultConfig := miner.createConfig(
			poolEndpoint,
			walletAddress,
			processingConfig)
		configBytes, err = json.Marshal(defaultConfig)
		if err != nil {
			return err
		}
	}
	err = ioutil.WriteFile(
		filepath.Join(miner.Base.executablePath, "config.json"),
		configBytes,
		0644)
	if err != nil {
		return err
	}
	miner.lastHashrate = 0.00
	return nil
}