Browse Source

Merge commit 'a63ecf6' into cgmerges

Conflict (not detected):
	API-README
Luke Dashjr 13 years ago
parent
commit
7d27587f3a
4 changed files with 29 additions and 0 deletions
  1. 2 0
      API-README
  2. 5 0
      api.c
  3. 17 0
      miner.c
  4. 5 0
      miner.h

+ 2 - 0
API-README

@@ -399,6 +399,8 @@ Modified API commands:
  'notify' - add '*Dev Throttle' (for BFL Singles)
  'notify' - add '*Dev Throttle' (for BFL Singles)
  'pools' - add 'Difficulty Accepted', 'Difficulty Rejected',
  'pools' - add 'Difficulty Accepted', 'Difficulty Rejected',
                'Difficulty Stale', 'Last Share Difficulty'
                'Difficulty Stale', 'Last Share Difficulty'
+ 'stats' - add 'Work Diff', 'Min Diff', 'Max Diff', 'Min Diff Count',
+               'Max Diff Count' to the pool stats
 
 
 ----------
 ----------
 
 

+ 5 - 0
api.c

@@ -2707,6 +2707,11 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine
 		root = api_add_bool(root, "Work Can Roll", &(pool_stats->canroll), 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_bool(root, "Work Had Expire", &(pool_stats->hadexpire), false);
 		root = api_add_uint32(root, "Work Roll Time", &(pool_stats->rolltime), false);
 		root = api_add_uint32(root, "Work Roll Time", &(pool_stats->rolltime), false);
+		root = api_add_diff(root, "Work Diff", &(pool_stats->last_diff), false);
+		root = api_add_diff(root, "Min Diff", &(pool_stats->min_diff), false);
+		root = api_add_diff(root, "Max Diff", &(pool_stats->max_diff), false);
+		root = api_add_uint32(root, "Min Diff Count", &(pool_stats->min_diff_count), false);
+		root = api_add_uint32(root, "Max Diff Count", &(pool_stats->max_diff_count), false);
 	}
 	}
 
 
 	if (extra)
 	if (extra)

+ 17 - 0
miner.c

@@ -2376,6 +2376,7 @@ static double DIFFEXACTONE = 269599466671506397946670150870196306736371444225405
  */
  */
 static void calc_diff(struct work *work)
 static void calc_diff(struct work *work)
 {
 {
+	struct cgminer_pool_stats *pool_stats = &(work->pool->cgminer_pool_stats);
 	double targ;
 	double targ;
 	int i;
 	int i;
 
 
@@ -2386,6 +2387,22 @@ static void calc_diff(struct work *work)
 	}
 	}
 
 
 	work->work_difficulty = DIFFEXACTONE / (targ ? : DIFFEXACTONE);
 	work->work_difficulty = DIFFEXACTONE / (targ ? : DIFFEXACTONE);
+
+	pool_stats->last_diff = work->work_difficulty;
+
+	if (work->work_difficulty == pool_stats->min_diff)
+		pool_stats->min_diff_count++;
+	else if (work->work_difficulty < pool_stats->min_diff || pool_stats->min_diff == 0) {
+		pool_stats->min_diff = work->work_difficulty;
+		pool_stats->min_diff_count = 1;
+	}
+
+	if (work->work_difficulty == pool_stats->max_diff)
+		pool_stats->max_diff_count++;
+	else if (work->work_difficulty > pool_stats->max_diff) {
+		pool_stats->max_diff = work->work_difficulty;
+		pool_stats->max_diff_count = 1;
+	}
 }
 }
 
 
 static void get_benchmark_work(struct work *work)
 static void get_benchmark_work(struct work *work)

+ 5 - 0
miner.h

@@ -353,6 +353,11 @@ struct cgminer_pool_stats {
 	bool canroll;
 	bool canroll;
 	bool hadexpire;
 	bool hadexpire;
 	uint32_t rolltime;
 	uint32_t rolltime;
+	double min_diff;
+	double max_diff;
+	double last_diff;
+	uint32_t min_diff_count;
+	uint32_t max_diff_count;
 };
 };
 
 
 struct cgpu_info {
 struct cgpu_info {