XMRig/TTMiner mining engine with profile management, stats collection,
circuit breakers, event system, supervisor, and SQLite persistence.
P2P node service stubbed (moved to core/go-p2p).
Ported from github.com/Snider/Mining/pkg/{mining,database,logging}
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
946 lines
30 KiB
Go
946 lines
30 KiB
Go
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
|
package docs
|
|
|
|
import "github.com/swaggo/swag"
|
|
|
|
const docTemplate = `{
|
|
"schemes": {{ marshal .Schemes }},
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"description": "{{escape .Description}}",
|
|
"title": "{{.Title}}",
|
|
"contact": {},
|
|
"version": "{{.Version}}"
|
|
},
|
|
"host": "{{.Host}}",
|
|
"basePath": "{{.BasePath}}",
|
|
"paths": {
|
|
"/doctor": {
|
|
"post": {
|
|
"description": "Performs a live check on all available miners to verify their installation status, version, and path.",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"system"
|
|
],
|
|
"summary": "Check miner installations",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.SystemInfo"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/info": {
|
|
"get": {
|
|
"description": "Retrieves live installation details for all miners, along with system information.",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"system"
|
|
],
|
|
"summary": "Get live miner installation information",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.SystemInfo"
|
|
}
|
|
},
|
|
"500": {
|
|
"description": "Internal server error",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners": {
|
|
"get": {
|
|
"description": "Get a list of all running miners",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "List all running miners",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.XMRigMiner"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/available": {
|
|
"get": {
|
|
"description": "Get a list of all available miners",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "List all available miners",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.AvailableMiner"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_name}": {
|
|
"delete": {
|
|
"description": "Stop a running miner by its name",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Stop a running miner",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Name",
|
|
"name": "miner_name",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_name}/hashrate-history": {
|
|
"get": {
|
|
"description": "Get historical hashrate data for a running miner",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Get miner hashrate history",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Name",
|
|
"name": "miner_name",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.HashratePoint"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_name}/logs": {
|
|
"get": {
|
|
"description": "Get the captured stdout/stderr output from a running miner",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Get miner log output",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Name",
|
|
"name": "miner_name",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_name}/stats": {
|
|
"get": {
|
|
"description": "Get statistics for a running miner",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Get miner stats",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Name",
|
|
"name": "miner_name",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.PerformanceMetrics"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_type}/install": {
|
|
"post": {
|
|
"description": "Install a new miner or update an existing one.",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Install or update a miner",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Type to install/update",
|
|
"name": "miner_type",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/miners/{miner_type}/uninstall": {
|
|
"delete": {
|
|
"description": "Removes all files for a specific miner.",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"miners"
|
|
],
|
|
"summary": "Uninstall a miner",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Miner Type to uninstall",
|
|
"name": "miner_type",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/profiles": {
|
|
"get": {
|
|
"description": "Get a list of all saved mining profiles",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "List all mining profiles",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"description": "Create and save a new mining profile",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "Create a new mining profile",
|
|
"parameters": [
|
|
{
|
|
"description": "Mining Profile",
|
|
"name": "profile",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"201": {
|
|
"description": "Created",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/profiles/{id}": {
|
|
"get": {
|
|
"description": "Get a mining profile by its ID",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "Get a specific mining profile",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Profile ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"put": {
|
|
"description": "Update an existing mining profile",
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "Update a mining profile",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Profile ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
},
|
|
{
|
|
"description": "Updated Mining Profile",
|
|
"name": "profile",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.MiningProfile"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"delete": {
|
|
"description": "Delete a mining profile by its ID",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "Delete a mining profile",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Profile ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/profiles/{id}/start": {
|
|
"post": {
|
|
"description": "Start a new miner with the configuration from a saved profile",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"profiles"
|
|
],
|
|
"summary": "Start a new miner using a profile",
|
|
"parameters": [
|
|
{
|
|
"type": "string",
|
|
"description": "Profile ID",
|
|
"name": "id",
|
|
"in": "path",
|
|
"required": true
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"$ref": "#/definitions/mining.XMRigMiner"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/update": {
|
|
"post": {
|
|
"description": "Checks if any installed miners have a new version available for download.",
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"tags": [
|
|
"system"
|
|
],
|
|
"summary": "Check for miner updates",
|
|
"responses": {
|
|
"200": {
|
|
"description": "OK",
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"mining.API": {
|
|
"type": "object",
|
|
"properties": {
|
|
"enabled": {
|
|
"type": "boolean"
|
|
},
|
|
"listenHost": {
|
|
"type": "string"
|
|
},
|
|
"listenPort": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"mining.AvailableMiner": {
|
|
"type": "object",
|
|
"properties": {
|
|
"description": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"mining.HashratePoint": {
|
|
"type": "object",
|
|
"properties": {
|
|
"hashrate": {
|
|
"type": "integer"
|
|
},
|
|
"timestamp": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"mining.InstallationDetails": {
|
|
"type": "object",
|
|
"properties": {
|
|
"config_path": {
|
|
"description": "Add path to the miner-specific config",
|
|
"type": "string"
|
|
},
|
|
"is_installed": {
|
|
"type": "boolean"
|
|
},
|
|
"miner_binary": {
|
|
"type": "string"
|
|
},
|
|
"path": {
|
|
"type": "string"
|
|
},
|
|
"version": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"mining.MiningProfile": {
|
|
"type": "object",
|
|
"properties": {
|
|
"config": {
|
|
"description": "The raw JSON config for the specific miner",
|
|
"type": "object"
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"minerType": {
|
|
"description": "e.g., \"xmrig\", \"ttminer\"",
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"mining.PerformanceMetrics": {
|
|
"type": "object",
|
|
"properties": {
|
|
"algorithm": {
|
|
"type": "string"
|
|
},
|
|
"extraData": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
},
|
|
"hashrate": {
|
|
"type": "integer"
|
|
},
|
|
"lastShare": {
|
|
"type": "integer"
|
|
},
|
|
"rejected": {
|
|
"type": "integer"
|
|
},
|
|
"shares": {
|
|
"type": "integer"
|
|
},
|
|
"uptime": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"mining.SystemInfo": {
|
|
"type": "object",
|
|
"properties": {
|
|
"architecture": {
|
|
"type": "string"
|
|
},
|
|
"available_cpu_cores": {
|
|
"type": "integer"
|
|
},
|
|
"go_version": {
|
|
"type": "string"
|
|
},
|
|
"installed_miners_info": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.InstallationDetails"
|
|
}
|
|
},
|
|
"os": {
|
|
"type": "string"
|
|
},
|
|
"timestamp": {
|
|
"type": "string"
|
|
},
|
|
"total_system_ram_gb": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
},
|
|
"mining.XMRigMiner": {
|
|
"type": "object",
|
|
"properties": {
|
|
"api": {
|
|
"$ref": "#/definitions/mining.API"
|
|
},
|
|
"configPath": {
|
|
"type": "string"
|
|
},
|
|
"full_stats": {
|
|
"$ref": "#/definitions/mining.XMRigSummary"
|
|
},
|
|
"hashrateHistory": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.HashratePoint"
|
|
}
|
|
},
|
|
"lowResHashrateHistory": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/mining.HashratePoint"
|
|
}
|
|
},
|
|
"miner_binary": {
|
|
"type": "string"
|
|
},
|
|
"name": {
|
|
"type": "string"
|
|
},
|
|
"path": {
|
|
"type": "string"
|
|
},
|
|
"running": {
|
|
"type": "boolean"
|
|
},
|
|
"url": {
|
|
"type": "string"
|
|
},
|
|
"version": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"mining.XMRigSummary": {
|
|
"type": "object",
|
|
"properties": {
|
|
"algo": {
|
|
"type": "string"
|
|
},
|
|
"algorithms": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"connection": {
|
|
"type": "object",
|
|
"properties": {
|
|
"accepted": {
|
|
"type": "integer"
|
|
},
|
|
"algo": {
|
|
"type": "string"
|
|
},
|
|
"avg_time": {
|
|
"type": "integer"
|
|
},
|
|
"avg_time_ms": {
|
|
"type": "integer"
|
|
},
|
|
"diff": {
|
|
"type": "integer"
|
|
},
|
|
"failures": {
|
|
"type": "integer"
|
|
},
|
|
"hashes_total": {
|
|
"type": "integer"
|
|
},
|
|
"ip": {
|
|
"type": "string"
|
|
},
|
|
"ping": {
|
|
"type": "integer"
|
|
},
|
|
"pool": {
|
|
"type": "string"
|
|
},
|
|
"rejected": {
|
|
"type": "integer"
|
|
},
|
|
"tls": {
|
|
"type": "string"
|
|
},
|
|
"tls-fingerprint": {
|
|
"type": "string"
|
|
},
|
|
"uptime": {
|
|
"type": "integer"
|
|
},
|
|
"uptime_ms": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"cpu": {
|
|
"type": "object",
|
|
"properties": {
|
|
"64_bit": {
|
|
"type": "boolean"
|
|
},
|
|
"aes": {
|
|
"type": "boolean"
|
|
},
|
|
"arch": {
|
|
"type": "string"
|
|
},
|
|
"assembly": {
|
|
"type": "string"
|
|
},
|
|
"avx2": {
|
|
"type": "boolean"
|
|
},
|
|
"backend": {
|
|
"type": "string"
|
|
},
|
|
"brand": {
|
|
"type": "string"
|
|
},
|
|
"cores": {
|
|
"type": "integer"
|
|
},
|
|
"family": {
|
|
"type": "integer"
|
|
},
|
|
"flags": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"l2": {
|
|
"type": "integer"
|
|
},
|
|
"l3": {
|
|
"type": "integer"
|
|
},
|
|
"model": {
|
|
"type": "integer"
|
|
},
|
|
"msr": {
|
|
"type": "string"
|
|
},
|
|
"nodes": {
|
|
"type": "integer"
|
|
},
|
|
"packages": {
|
|
"type": "integer"
|
|
},
|
|
"proc_info": {
|
|
"type": "integer"
|
|
},
|
|
"stepping": {
|
|
"type": "integer"
|
|
},
|
|
"threads": {
|
|
"type": "integer"
|
|
},
|
|
"x64": {
|
|
"type": "boolean"
|
|
}
|
|
}
|
|
},
|
|
"donate_level": {
|
|
"type": "integer"
|
|
},
|
|
"features": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"hashrate": {
|
|
"type": "object",
|
|
"properties": {
|
|
"highest": {
|
|
"type": "number"
|
|
},
|
|
"total": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"hugepages": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"kind": {
|
|
"type": "string"
|
|
},
|
|
"paused": {
|
|
"type": "boolean"
|
|
},
|
|
"resources": {
|
|
"type": "object",
|
|
"properties": {
|
|
"hardware_concurrency": {
|
|
"type": "integer"
|
|
},
|
|
"load_average": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"memory": {
|
|
"type": "object",
|
|
"properties": {
|
|
"free": {
|
|
"type": "integer"
|
|
},
|
|
"resident_set_memory": {
|
|
"type": "integer"
|
|
},
|
|
"total": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"restricted": {
|
|
"type": "boolean"
|
|
},
|
|
"results": {
|
|
"type": "object",
|
|
"properties": {
|
|
"avg_time": {
|
|
"type": "integer"
|
|
},
|
|
"avg_time_ms": {
|
|
"type": "integer"
|
|
},
|
|
"best": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"diff_current": {
|
|
"type": "integer"
|
|
},
|
|
"hashes_total": {
|
|
"type": "integer"
|
|
},
|
|
"shares_good": {
|
|
"type": "integer"
|
|
},
|
|
"shares_total": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
},
|
|
"ua": {
|
|
"type": "string"
|
|
},
|
|
"uptime": {
|
|
"type": "integer"
|
|
},
|
|
"version": {
|
|
"type": "string"
|
|
},
|
|
"worker_id": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|
var SwaggerInfo = &swag.Spec{
|
|
Version: "1.0",
|
|
Host: "localhost:8080",
|
|
BasePath: "/api/v1/mining",
|
|
Schemes: []string{},
|
|
Title: "Mining API",
|
|
Description: "This is a sample server for a mining application.",
|
|
InfoInstanceName: "swagger",
|
|
SwaggerTemplate: docTemplate,
|
|
LeftDelim: "{{",
|
|
RightDelim: "}}",
|
|
}
|
|
|
|
func init() {
|
|
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
|
}
|