Create extra work fields when generating GBT work.
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
diff --git a/cgminer.c b/cgminer.c
index 6834af1..04b21da 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1498,7 +1498,9 @@ static unsigned char *__gbt_merkleroot(struct pool *pool)
}
return merkle_hash;
}
-
+
+static void calc_diff(struct work *work, int known);
+
static void gen_gbt_work(struct pool *pool, struct work *work)
{
unsigned char *merkleroot;
@@ -1508,19 +1510,35 @@ static void gen_gbt_work(struct pool *pool, struct work *work)
merkleroot = __gbt_merkleroot(pool);
memcpy(work->data, &pool->gbt_version, 4);
hex2bin(work->data + 4, pool->previousblockhash, 32);
- memcpy(work->data + 4 + 32, merkleroot, 32);
memcpy(work->data + 4 + 32 + 32, &pool->curtime, 4);
hex2bin(work->data + 4 + 32 + 32 + 4, pool->gbt_bits, 4);
- memset(work->data + 4 + 32 + 32 + 4 + 4, 0, 4); /* nonce */
+
+ hex2bin(work->target, pool->gbt_target, 32);
mutex_unlock(&pool->gbt_lock);
+ memcpy(work->data + 4 + 32, merkleroot, 32);
+ 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, 4 + 32 + 32 + 4 + 4 + 4);
+ char *header = bin2hex(work->data, 128);
applog(LOG_DEBUG, "Generated GBT header %s", header);
free(header);
}
+ local_work++;
+ work->pool = pool;
+ work->gbt = true;
+ work->id = total_work++;
+ work->longpoll = false;
+ work->getwork_mode = GETWORK_MODE_GBT;
+ work->work_block = work_block;
+ calc_diff(work, 0);
+ gettimeofday(&work->tv_staged, NULL);
+
free(merkleroot);
}
diff --git a/miner.h b/miner.h
index 6645f17..e165bcb 100644
--- a/miner.h
+++ b/miner.h
@@ -909,6 +909,7 @@ struct pool {
#define GETWORK_MODE_LP 'L'
#define GETWORK_MODE_BENCHMARK 'B'
#define GETWORK_MODE_STRATUM 'S'
+#define GETWORK_MODE_GBT 'G'
struct work {
unsigned char data[128];