mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Add API commands and modify output to support pool quota displaying and changing.
This commit is contained in:
parent
e8a1c9ebd1
commit
d0a70eb0ee
16
API-README
16
API-README
@ -188,6 +188,10 @@ The list of requests - a (*) means it requires privileged access - and replies:
|
||||
stating the results of changing pool priorities
|
||||
See usage below
|
||||
|
||||
poolquota|N,Q (*)
|
||||
none There is no reply section just the STATUS section
|
||||
stating the results of changing pool quota to Q
|
||||
|
||||
disablepool|N (*)
|
||||
none There is no reply section just the STATUS section
|
||||
stating the results of disabling pool N
|
||||
@ -486,6 +490,16 @@ miner.php - an example web page to access the API
|
||||
Feature Changelog for external applications using the API:
|
||||
|
||||
|
||||
API V1.30 (cgminer v3.4.3)
|
||||
|
||||
Added API command:
|
||||
'poolquota' - Set pool quota for load-balance strategy.
|
||||
|
||||
Modified API command:
|
||||
'pools' - add 'Quota'
|
||||
|
||||
---------
|
||||
|
||||
API V1.29 (cgminer v3.4.1)
|
||||
|
||||
Muticast identification added to the API
|
||||
@ -578,7 +592,7 @@ Added API commands:
|
||||
Modified API commands:
|
||||
'summary' - add 'Best Share'
|
||||
|
||||
Modifed output:
|
||||
Modified output:
|
||||
each MMQ shows up as 4 devices, each with it's own stats
|
||||
|
||||
----------
|
||||
|
52
api.c
52
api.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Andrew Smith
|
||||
* Copyright 2011-2012 Con Kolivas
|
||||
* Copyright 2011-2013 Con Kolivas
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
@ -135,7 +135,7 @@ static const char SEPARATOR = '|';
|
||||
#define SEPSTR "|"
|
||||
static const char GPUSEP = ',';
|
||||
|
||||
static const char *APIVERSION = "1.29";
|
||||
static const char *APIVERSION = "1.30";
|
||||
static const char *DEAD = "Dead";
|
||||
#if defined(HAVE_OPENCL) || defined(HAVE_AN_FPGA) || defined(HAVE_AN_ASIC)
|
||||
static const char *SICK = "Sick";
|
||||
@ -422,6 +422,9 @@ static const char *JSON_PARAMETER = "parameter";
|
||||
#define MSG_ASCSETERR 120
|
||||
#endif
|
||||
|
||||
#define MSG_INVNEG 121
|
||||
#define MSG_SETQUOTA 122
|
||||
|
||||
enum code_severity {
|
||||
SEVERITY_ERR,
|
||||
SEVERITY_WARN,
|
||||
@ -582,6 +585,8 @@ struct CODES {
|
||||
{ SEVERITY_SUCC, MSG_SETCONFIG,PARAM_SET, "Set config '%s' to %d" },
|
||||
{ SEVERITY_ERR, MSG_UNKCON, PARAM_STR, "Unknown config '%s'" },
|
||||
{ SEVERITY_ERR, MSG_INVNUM, PARAM_BOTH, "Invalid number (%d) for '%s' range is 0-9999" },
|
||||
{ SEVERITY_ERR, MSG_INVNEG, PARAM_BOTH, "Invalid negative number (%d) for '%s'" },
|
||||
{ SEVERITY_SUCC, MSG_SETQUOTA,PARAM_SET, "Set pool '%s' to quota %d'" },
|
||||
{ SEVERITY_ERR, MSG_CONPAR, PARAM_NONE, "Missing config parameters 'name,N'" },
|
||||
{ SEVERITY_ERR, MSG_CONVAL, PARAM_STR, "Missing config value N for '%s,N'" },
|
||||
{ SEVERITY_SUCC, MSG_USBSTA, PARAM_NONE, "USB Statistics" },
|
||||
@ -2145,6 +2150,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
||||
root = api_add_escape(root, "URL", pool->rpc_url, false);
|
||||
root = api_add_string(root, "Status", status, false);
|
||||
root = api_add_int(root, "Priority", &(pool->prio), false);
|
||||
root = api_add_int(root, "Quota", &pool->quota, false);
|
||||
root = api_add_string(root, "Long Poll", lp, false);
|
||||
root = api_add_uint(root, "Getworks", &(pool->getwork_requested), false);
|
||||
root = api_add_int(root, "Accepted", &(pool->accepted), false);
|
||||
@ -2617,6 +2623,47 @@ static void poolpriority(struct io_data *io_data, __maybe_unused SOCKETTYPE c, c
|
||||
message(io_data, MSG_POOLPRIO, 0, NULL, isjson);
|
||||
}
|
||||
|
||||
static void poolquota(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
||||
{
|
||||
struct pool *pool;
|
||||
int quota, id;
|
||||
char *comma;
|
||||
|
||||
if (total_pools == 0) {
|
||||
message(io_data, MSG_NOPOOL, 0, NULL, isjson);
|
||||
return;
|
||||
}
|
||||
|
||||
if (param == NULL || *param == '\0') {
|
||||
message(io_data, MSG_MISPID, 0, NULL, isjson);
|
||||
return;
|
||||
}
|
||||
|
||||
comma = strchr(param, ',');
|
||||
if (!comma) {
|
||||
message(io_data, MSG_CONVAL, 0, param, isjson);
|
||||
return;
|
||||
}
|
||||
|
||||
*(comma++) = '\0';
|
||||
|
||||
id = atoi(param);
|
||||
if (id < 0 || id >= total_pools) {
|
||||
message(io_data, MSG_INVPID, id, NULL, isjson);
|
||||
return;
|
||||
}
|
||||
pool = pools[id];
|
||||
|
||||
quota = atoi(comma);
|
||||
if (quota < 0) {
|
||||
message(io_data, MSG_INVNEG, quota, pool->rpc_url, isjson);
|
||||
return;
|
||||
}
|
||||
|
||||
pool->quota = quota;
|
||||
message(io_data, MSG_SETQUOTA, quota, pool->rpc_url, isjson);
|
||||
}
|
||||
|
||||
static void disablepool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
||||
{
|
||||
struct pool *pool;
|
||||
@ -3831,6 +3878,7 @@ struct CMDS {
|
||||
{ "switchpool", switchpool, true },
|
||||
{ "addpool", addpool, true },
|
||||
{ "poolpriority", poolpriority, true },
|
||||
{ "poolquota", poolquota, true },
|
||||
{ "enablepool", enablepool, true },
|
||||
{ "disablepool", disablepool, true },
|
||||
{ "removepool", removepool, true },
|
||||
|
Loading…
x
Reference in New Issue
Block a user