Browse Source

Benchmark: Add 2D work support

Luke Dashjr 12 years ago
parent
commit
fffa2407f8
1 changed files with 25 additions and 0 deletions
  1. 25 0
      miner.c

+ 25 - 0
miner.c

@@ -8730,6 +8730,8 @@ void stratum_work_clean(struct stratum_work * const swork)
 
 bool pool_has_usable_swork(const struct pool * const pool)
 {
+	if (opt_benchmark)
+		return true;
 	if (pool->swork.tr)
 	{
 		// GBT
@@ -11512,6 +11514,29 @@ int main(int argc, char *argv[])
 		enable_pool(pool);
 		pool->idle = false;
 		successful_connect = true;
+		
+		{
+			struct stratum_work * const swork = &pool->swork;
+			const int branchcount = 15;  // 1 MB block
+			const size_t branchdatasz = branchcount * 0x20;
+			const size_t coinbase_sz = 6 * 1024;
+			
+			bytes_resize(&swork->coinbase, coinbase_sz);
+			memset(bytes_buf(&swork->coinbase), '\xff', coinbase_sz);
+			swork->nonce2_offset = 0;
+			
+			bytes_resize(&swork->merkle_bin, branchdatasz);
+			memset(bytes_buf(&swork->merkle_bin), '\xff', branchdatasz);
+			swork->merkles = branchcount;
+			
+			memset(swork->header1, '\xff', 36);
+			swork->ntime = 0x7fffffff;
+			timer_unset(&swork->tv_received);
+			memset(swork->diffbits, '\0', 4);
+			swork->diff = 1;
+			pool->nonce2sz = swork->n2size = GBT_XNONCESZ;
+			pool->nonce2 = 0;
+		}
 	}
 	
 	if (opt_unittest) {