Browse Source

Merge commit '5095ed2' into bfgminer

Conflicts:
	API-README
Luke Dashjr 13 years ago
parent
commit
3a058c0c2a
5 changed files with 52 additions and 5 deletions
  1. 11 0
      API-README
  2. 6 1
      api.c
  3. 4 0
      miner.h
  4. 17 1
      miner.php
  5. 14 3
      util.c

+ 11 - 0
API-README

@@ -340,6 +340,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.17b (BFGMiner v2.7.1)
 
 Modified API commands:

+ 6 - 1
api.c

@@ -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";
@@ -1277,6 +1277,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)
@@ -2602,6 +2603,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 - 0
miner.h

@@ -342,6 +342,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 {

+ 17 - 1
miner.php

@@ -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'];
 #

+ 14 - 3
util.c

@@ -67,6 +67,9 @@ struct header_info {
 	char		*lp_path;
 	int		rolltime;
 	char		*reason;
+	bool		hadrolltime;
+	bool		canroll;
+	bool		hadexpire;
 };
 
 struct tq_ent {
@@ -166,14 +169,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);
 		}
@@ -267,7 +274,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;
@@ -401,6 +408,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) {