Hash1 is only used by the deprecated cpu mining code and never changes so remove it from the work struct and bypass needing to process the value for all other mining.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
diff --git a/cgminer.c b/cgminer.c
index f428ec0..459724f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -111,7 +111,7 @@ int gpu_threads;
bool opt_scrypt;
#endif
#endif
-bool opt_restart = true;
+bool opt_restart;
static bool opt_nogpu;
struct list_head scan_devices;
@@ -1498,7 +1498,6 @@ static void gen_gbt_work(struct pool *pool, struct work *work)
memset(work->data + 4 + 32 + 32 + 4 + 4, 0, 4); /* nonce */
hex2bin(work->data + 4 + 32 + 32 + 4 + 4 + 4, "000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000", 48);
- hex2bin(work->hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
if (opt_debug) {
char *header = bin2hex(work->data, 128);
@@ -1597,11 +1596,6 @@ static bool getwork_decode(json_t *res_val, struct work *work)
calc_midstate(work);
}
- if (!jobj_binary(res_val, "hash1", work->hash1, sizeof(work->hash1), false)) {
- // Always the same anyway
- memcpy(work->hash1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0", 64);
- }
-
if (unlikely(!jobj_binary(res_val, "target", work->target, sizeof(work->target), true))) {
applog(LOG_ERR, "JSON inval target");
return false;
@@ -5101,8 +5095,8 @@ static void set_work_target(struct work *work, int diff)
static void gen_stratum_work(struct pool *pool, struct work *work)
{
unsigned char *coinbase, merkle_root[36], merkle_sha[68], *merkle_hash;
- char header[260], hash1[132], *nonce2;
int len, cb1_len, n1_len, cb2_len, i;
+ char header[260], *nonce2;
uint32_t *data32, *swap32;
memset(work->job_id, 0, 64);
@@ -5171,9 +5165,6 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
if (unlikely(!hex2bin(work->data, header, 128)))
quit(1, "Failed to convert header to data in gen_stratum_work");
calc_midstate(work);
- sprintf(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000");
- if (unlikely(!hex2bin(work->hash1, hash1, 64)))
- quit(1, "Failed to convert hash1 in gen_stratum_work");
set_work_target(work, work->sdiff);
diff --git a/driver-cpu.c b/driver-cpu.c
index e3a74de..7390dfc 100644
--- a/driver-cpu.c
+++ b/driver-cpu.c
@@ -226,6 +226,7 @@ double bench_algo_stage3(
// Use a random work block pulled from a pool
static uint8_t bench_block[] = { CGMINER_BENCHMARK_BLOCK };
struct work work __attribute__((aligned(128)));
+ unsigned char hash1[64];
size_t bench_size = sizeof(work);
size_t work_size = sizeof(bench_block);
@@ -240,6 +241,8 @@ double bench_algo_stage3(
uint32_t max_nonce = (1<<22);
uint32_t last_nonce = 0;
+ hex2bin(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
+
gettimeofday(&start, 0);
{
sha256_func func = sha256_funcs[algo];
@@ -247,7 +250,7 @@ double bench_algo_stage3(
&dummy,
work.midstate,
work.data,
- work.hash1,
+ hash1,
work.hash,
work.target,
max_nonce,
@@ -799,11 +802,12 @@ static bool cpu_thread_init(struct thr_info *thr)
static int64_t cpu_scanhash(struct thr_info *thr, struct work *work, int64_t max_nonce)
{
const int thr_id = thr->id;
-
+ unsigned char hash1[64];
uint32_t first_nonce = work->blk.nonce;
uint32_t last_nonce;
bool rc;
+ hex2bin(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
CPUSearch:
last_nonce = first_nonce;
rc = false;
@@ -815,7 +819,7 @@ CPUSearch:
thr,
work->midstate,
work->data,
- work->hash1,
+ hash1,
work->hash,
work->target,
max_nonce,
diff --git a/miner.h b/miner.h
index 698691d..2b52eaa 100644
--- a/miner.h
+++ b/miner.h
@@ -935,7 +935,6 @@ struct pool {
struct work {
unsigned char data[128];
- unsigned char hash1[64];
unsigned char midstate[32];
unsigned char target[32];
unsigned char hash[32];