Browse Source

work2d: Accept nonce difficulty with submissions

Luke Dashjr 12 years ago
parent
commit
7d6540aeb3
3 changed files with 5 additions and 3 deletions
  1. 2 1
      driver-stratum.c
  2. 2 1
      work2d.c
  3. 1 1
      work2d.h

+ 2 - 1
driver-stratum.c

@@ -368,6 +368,7 @@ void stratumsrv_mining_submit(struct bufferevent *bev, json_t *params, const cha
 	const char * const nonce = __json_array_string(params, 4);
 	uint8_t xnonce2[work2d_xnonce2sz];
 	uint32_t ntime_n, nonce_n;
+	const float nonce_diff = 1;
 	bool is_stale;
 	
 	if (unlikely(!client))
@@ -396,7 +397,7 @@ void stratumsrv_mining_submit(struct bufferevent *bev, json_t *params, const cha
 	ntime_n = be32toh(ntime_n);
 	hex2bin((void*)&nonce_n, nonce, 4);
 	nonce_n = le32toh(nonce_n);
-	if (!work2d_submit_nonce(thr, &ssj->swork, &ssj->tv_prepared, xnonce2, *xnonce1_p, nonce_n, ntime_n, &is_stale))
+	if (!work2d_submit_nonce(thr, &ssj->swork, &ssj->tv_prepared, xnonce2, *xnonce1_p, nonce_n, ntime_n, &is_stale, nonce_diff))
 		_stratumsrv_failure(bev, idstr, 23, "H-not-zero");
 	else
 	if (is_stale)

+ 2 - 1
work2d.c

@@ -93,7 +93,7 @@ void work2d_gen_dummy_work(struct work * const work, struct stratum_work * const
 	gen_stratum_work2(work, swork);
 }
 
-bool work2d_submit_nonce(struct thr_info * const thr, struct stratum_work * const swork, const struct timeval * const tvp_prepared, const void * const xnonce2, const uint32_t xnonce1, const uint32_t nonce, const uint32_t ntime, bool * const out_is_stale)
+bool work2d_submit_nonce(struct thr_info * const thr, struct stratum_work * const swork, const struct timeval * const tvp_prepared, const void * const xnonce2, const uint32_t xnonce1, const uint32_t nonce, const uint32_t ntime, bool * const out_is_stale, const float nonce_diff)
 {
 	struct work _work, *work;
 	bool rv;
@@ -102,6 +102,7 @@ bool work2d_submit_nonce(struct thr_info * const thr, struct stratum_work * cons
 	work = &_work;
 	work2d_gen_dummy_work(work, swork, tvp_prepared, xnonce2, xnonce1);
 	*(uint32_t *)&work->data[68] = htobe32(ntime);
+	work->nonce_diff = nonce_diff;
 	
 	// Check if it's stale, if desired
 	if (out_is_stale)

+ 1 - 1
work2d.h

@@ -14,6 +14,6 @@ extern void release_work2d_(uint32_t xnonce1);
 extern int work2d_pad_xnonce_size(const struct stratum_work *);
 extern void *work2d_pad_xnonce(void *buf, const struct stratum_work *, bool hex);
 extern void work2d_gen_dummy_work(struct work *, struct stratum_work *, const struct timeval *tvp_prepared, const void *xnonce2, uint32_t xnonce1);
-extern bool work2d_submit_nonce(struct thr_info *, struct stratum_work *, const struct timeval *tvp_prepared, const void *xnonce2, uint32_t xnonce1, uint32_t nonce, uint32_t ntime, bool *out_is_stale);
+extern bool work2d_submit_nonce(struct thr_info *, struct stratum_work *, const struct timeval *tvp_prepared, const void *xnonce2, uint32_t xnonce1, uint32_t nonce, uint32_t ntime, bool *out_is_stale, float nonce_diff);
 
 #endif