Skip to content

OsoianMarcel/claymore-go

Repository files navigation

claymore-go

Go library used to get claymore stats in human readable model

license

Example of simple web server using this library

package main

import (
	"github.com/OsoianMarcel/claymore-go"
	"net/http"
	"encoding/json"
)

type ErrorResponse struct {
	Error string `json:"error"`
}

type DataResponse struct {
	Data interface{} `json:"data"`
}

type ExtraResponse struct {
	HighestTemp claymore.TempAndFanReport `json:"highest_temp"`
}

type StatsResponse struct {
	Stats claymore.StatsModel `json:"stats"`
	Extra ExtraResponse       `json:"extra"`
}

func main() {
	cc := claymore.NewClient("localhost:3333")

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("Content-Type", "application/json")

		stats, err := cc.GetStats()

		if err != nil {
			w.WriteHeader(http.StatusServiceUnavailable)
			json.NewEncoder(w).Encode(ErrorResponse{err.Error()})
			return
		}

		extraResp := ExtraResponse{}

		if ht, err := stats.GetHighestTemp(); err == nil {
			extraResp.HighestTemp = ht
		}

		statsResp := StatsResponse{stats, extraResp}

		json.NewEncoder(w).Encode(DataResponse{statsResp})
	})

	http.ListenAndServe(":8080", nil)
}

Server output

{
	"data": {
		"stats": {
			"miner_version": "10.5 - ETH",
			"running_minutes": 1409,
			"eth_report": {
				"total_mhs": 80941,
				"shares": 1640,
				"rejected_shares": 1,
				"invalid_shares": 37,
				"pool_switches": 1,
				"mhs_per_gpu": [
					{
						"mhs": 13344,
						"gpu": 0
					},
					{
						"mhs": 13352,
						"gpu": 1
					},
					{
						"mhs": 13398,
						"gpu": 2
					},
					{
						"mhs": 14151,
						"gpu": 3
					},
					{
						"mhs": 13352,
						"gpu": 4
					},
					{
						"mhs": 13342,
						"gpu": 5
					}
				]
			},
			"alt_report": {
				"total_mhs": 0,
				"shares": 0,
				"rejected_shares": 0,
				"invalid_shares": 0,
				"pool_switches": 0,
				"mhs_per_gpu": [
					{
						"mhs": 0,
						"gpu": 0
					},
					{
						"mhs": 0,
						"gpu": 1
					},
					{
						"mhs": 0,
						"gpu": 2
					},
					{
						"mhs": 0,
						"gpu": 3
					},
					{
						"mhs": 0,
						"gpu": 4
					},
					{
						"mhs": 0,
						"gpu": 5
					}
				]
			},
			"temp_and_fan_reports": [
				{
					"temp": 66,
					"fan": 40,
					"gpu": 0
				},
				{
					"temp": 66,
					"fan": 40,
					"gpu": 1
				},
				{
					"temp": 67,
					"fan": 41,
					"gpu": 2
				},
				{
					"temp": 67,
					"fan": 40,
					"gpu": 3
				},
				{
					"temp": 67,
					"fan": 40,
					"gpu": 4
				},
				{
					"temp": 63,
					"fan": 80,
					"gpu": 5
				}
			],
			"pools": [
				"eu1.ethermine.org:4444"
			]
		},
		"extra": {
			"highest_temp": {
				"temp": 67,
				"fan": 41,
				"gpu": 2
			}
		}
	}
}

Contribute

Contributions to the package are always welcome!

Donation

Give me a Star if you like it!

License

All contents of this package are licensed under the MIT license.

About

Claymore Client written in Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages