Browse Source

Merge branch 'master' of github.com:ckolivas/cgminer

nfactor-troky
Con Kolivas 12 years ago
parent
commit
5095ed29a1
  1. 11
      API-README
  2. 7
      api.c
  3. 4
      miner.h
  4. 18
      miner.php
  5. 17
      util.c

11
API-README

@ -339,6 +339,17 @@ miner.php - an example web page to access the API @@ -339,6 +339,17 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
API V1.18
Modified API commands:
'stats' - add 'Work Had Roll Time', 'Work Can Roll', 'Work Had Expire',
'Work Roll Time' to the pool stats
Modified API commands:
'config' - include 'ScanTime'
----------
API V1.17 (cgminer v2.7.1)
Added API commands:

7
api.c

@ -166,7 +166,7 @@ static const char SEPARATOR = '|'; @@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
#define SEPSTR "|"
static const char GPUSEP = ',';
static const char *APIVERSION = "1.17";
static const char *APIVERSION = "1.18";
static const char *DEAD = "Dead";
static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
@ -1256,6 +1256,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, @@ -1256,6 +1256,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
root = api_add_const(root, "Device Code", DEVICECODE, false);
root = api_add_const(root, "OS", OSINFO, false);
root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
root = api_add_int(root, "ScanTime", &opt_scantime, false);
root = print_data(root, buf, isjson);
if (isjson)
@ -2676,6 +2677,10 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine @@ -2676,6 +2677,10 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine
root = api_add_timeval(root, "Pool Max", &(pool_stats->getwork_wait_max), false);
root = api_add_timeval(root, "Pool Min", &(pool_stats->getwork_wait_min), false);
root = api_add_double(root, "Pool Av", &(pool_stats->getwork_wait_rolling), false);
root = api_add_bool(root, "Work Had Roll Time", &(pool_stats->hadrolltime), false);
root = api_add_bool(root, "Work Can Roll", &(pool_stats->canroll), false);
root = api_add_bool(root, "Work Had Expire", &(pool_stats->hadexpire), false);
root = api_add_uint32(root, "Work Roll Time", &(pool_stats->rolltime), false);
}
if (extra)

4
miner.h

@ -307,6 +307,10 @@ struct cgminer_pool_stats { @@ -307,6 +307,10 @@ struct cgminer_pool_stats {
struct timeval getwork_wait_max;
struct timeval getwork_wait_min;
double getwork_wait_rolling;
bool hadrolltime;
bool canroll;
bool hadexpire;
uint32_t rolltime;
};
struct cgpu_info {

18
miner.php

@ -84,8 +84,24 @@ $mobilesum = array( @@ -84,8 +84,24 @@ $mobilesum = array(
'DEVS+NOTIFY' => array('DEVS.MHS av', 'DEVS.Accepted', 'DEVS.Rejected', 'DEVS.Utility'),
'POOL' => array('Accepted', 'Rejected'));
#
$statspage = array(
'DATE' => null,
'RIGS' => null,
'SUMMARY' => array('Elapsed', 'MHS av', 'Found Blocks=Blks',
'Accepted', 'Rejected=Rej', 'Utility',
'Hardware Errors=HW Errs', 'Network Blocks=Net Blks',
'Work Utility'),
'COIN' => array('*'),
'STATS' => array('*'));
#
$statssum = array(
'SUMMARY' => array('MHS av', 'Found Blocks', 'Accepted',
'Rejected', 'Utility', 'Hardware Errors',
'Work Utility'));
#
# customsummarypages is an array of these Custom Summary Pages
$customsummarypages = array('Mobile' => array($mobilepage, $mobilesum));
$customsummarypages = array('Mobile' => array($mobilepage, $mobilesum),
'Stats' => array($statspage, $statssum));
#
$here = $_SERVER['PHP_SELF'];
#

17
util.c

@ -58,6 +58,9 @@ struct header_info { @@ -58,6 +58,9 @@ struct header_info {
char *lp_path;
int rolltime;
char *reason;
bool hadrolltime;
bool canroll;
bool hadexpire;
};
struct tq_ent {
@ -157,14 +160,18 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data) @@ -157,14 +160,18 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
applog(LOG_DEBUG, "HTTP hdr(%s): %s", key, val);
if (!strcasecmp("X-Roll-Ntime", key)) {
hi->hadrolltime = true;
if (!strncasecmp("N", val, 1))
applog(LOG_DEBUG, "X-Roll-Ntime: N found");
else {
hi->canroll = true;
/* Check to see if expire= is supported and if not, set
* the rolltime to the default scantime */
if (strlen(val) > 7 && !strncasecmp("expire=", val, 7))
if (strlen(val) > 7 && !strncasecmp("expire=", val, 7)) {
sscanf(val + 7, "%d", &hi->rolltime);
else
hi->hadexpire = true;
} else
hi->rolltime = opt_scantime;
applog(LOG_DEBUG, "X-Roll-Ntime expiry set to %d", hi->rolltime);
}
@ -258,7 +265,7 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -258,7 +265,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
{
long timeout = longpoll ? (60 * 60) : 60;
struct data_buffer all_data = {NULL, 0};
struct header_info hi = {NULL, 0, NULL};
struct header_info hi = {NULL, 0, NULL, false, false, false};
char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE];
struct curl_slist *headers = NULL;
@ -388,6 +395,10 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -388,6 +395,10 @@ json_t *json_rpc_call(CURL *curl, const char *url,
}
*rolltime = hi.rolltime;
pool->cgminer_pool_stats.rolltime = hi.rolltime;
pool->cgminer_pool_stats.hadrolltime = hi.hadrolltime;
pool->cgminer_pool_stats.canroll = hi.canroll;
pool->cgminer_pool_stats.hadexpire = hi.hadexpire;
val = JSON_LOADS(all_data.buf, &err);
if (!val) {

Loading…
Cancel
Save