Browse Source

Provide a way for drivers to submit work that it has internally rolled the ntime value by returning the amount it has ntime rolled to be added.

Con Kolivas 12 years ago
parent
commit
4c79252dc8
2 changed files with 20 additions and 0 deletions
  1. 18 0
      cgminer.c
  2. 2 0
      miner.h

+ 18 - 0
cgminer.c

@@ -6084,6 +6084,24 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 	return ret;
 }
 
+/* Allows drivers to submit work items where the driver has changed the ntime
+ * value by noffset. Must be only used with a work protocol that does not ntime
+ * roll itself intrinsically to generate work (eg stratum). */
+bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
+			  int noffset)
+{
+	unsigned char bin[4];
+	uint32_t h32, *be32 = (uint32_t *)bin;
+
+	hex2bin(bin, work->ntime, 4);
+	h32 = be32toh(*be32) + noffset;
+	*be32 = htobe32(h32);
+	free(work->ntime);
+	work->ntime = bin2hex(bin, 4);
+
+	return submit_nonce(thr, work, nonce);
+}
+
 static inline bool abandon_work(struct work *work, struct timeval *wdiff, uint64_t hashes)
 {
 	if (wdiff->tv_sec > opt_scantime ||

+ 2 - 0
miner.h

@@ -1388,6 +1388,8 @@ extern void inc_hw_errors(struct thr_info *thr);
 extern bool test_nonce(struct work *work, uint32_t nonce);
 extern void submit_tested_work(struct thr_info *thr, struct work *work);
 extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
+extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,
+			  int noffset);
 extern struct work *get_queued(struct cgpu_info *cgpu);
 extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
 extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);