Commit cb42ddbf7d8466f4a51e8d37490b87f234d6427b

kanoi 2014-06-25T11:39:26

Merge pull request #616 from kanoi/master noncedup - give access to the internal stats

diff --git a/miner.h b/miner.h
index 2e24952..d9d5da1 100644
--- a/miner.h
+++ b/miner.h
@@ -1558,6 +1558,7 @@ extern struct api_data *api_add_percent(struct api_data *root, char *name, doubl
 extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data);
 
 extern void dupalloc(struct cgpu_info *cgpu, int timelimit);
+extern void dupcounters(struct cgpu_info *cgpu, uint64_t *checked, uint64_t *dups);
 extern bool isdupnonce(struct cgpu_info *cgpu, struct work *work, uint32_t nonce);
 
 #endif /* __MINER_H__ */
diff --git a/noncedup.c b/noncedup.c
index 3479f82..6b94fd6 100644
--- a/noncedup.c
+++ b/noncedup.c
@@ -24,7 +24,7 @@ struct dupdata {
 	K_LIST *nfree_list;
 	K_STORE *nonce_list;
 	uint64_t checked;
-	uint64_t dup;
+	uint64_t dups;
 };
 
 void dupalloc(struct cgpu_info *cgpu, int timelimit)
@@ -42,6 +42,19 @@ void dupalloc(struct cgpu_info *cgpu, int timelimit)
 	cgpu->dup_data = dup;
 }
 
+void dupcounters(struct cgpu_info *cgpu, uint64_t *checked, uint64_t *dups)
+{
+	struct dupdata *dup = (struct dupdata *)(cgpu->dup_data);
+
+	if (!dup) {
+		*checked = 0;
+		*dups = 0;
+	} else {
+		*checked = dup->checked;
+		*dups = dup->dups;
+	}
+}
+
 bool isdupnonce(struct cgpu_info *cgpu, struct work *work, uint32_t nonce)
 {
 	struct dupdata *dup = (struct dupdata *)(cgpu->dup_data);
@@ -80,7 +93,7 @@ bool isdupnonce(struct cgpu_info *cgpu, struct work *work, uint32_t nonce)
 	K_WUNLOCK(dup->nfree_list);
 
 	if (!unique)
-		dup->dup++;
+		dup->dups++;
 
 	return !unique;
 }