Browse Source

Generate the work target in gen_stratum_work, setting default diff to 1 in case it is not yet set.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
636f4b14d7
  1. 17
      cgminer.c
  2. 1
      util.c

17
cgminer.c

@ -4276,9 +4276,10 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len) @@ -4276,9 +4276,10 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
static void gen_stratum_work(struct pool *pool, struct work *work)
{
unsigned char merkle_root[32], merkle_sha[64], *merkle_hash;
char header[256], hash1[128], *coinbase, *nonce2;
char header[256], hash1[128], *coinbase, *nonce2, *buf;
uint32_t *data32, *swap32;
int len, i, diff;
uint64_t diff, diff64;
int len, i;
mutex_lock(&pool->pool_lock);
@ -4328,12 +4329,24 @@ static void gen_stratum_work(struct pool *pool, struct work *work) @@ -4328,12 +4329,24 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
free(merkle_hash);
/* Convert hex data to binary data for work */
if (!hex2bin(work->data, header, 128))
quit(1, "Failed to convert header to data in gen_stratum_work");
calc_midstate(work);
sprintf(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000");
if (!hex2bin(work->hash1, hash1, 64))
quit(1, "Failed to convert hash1 in gen_stratum_work");
/* Generate target as hex where 0x00000000FFFFFFFF is diff 1 */
diff64 = 0x00000000FFFFFFFFULL * diff;
diff64 = ~htobe64(diff64);
sprintf((char *)work->target, "ffffffffffffffffffffffffffffffffffffffffffffffff");
buf = bin2hex((const unsigned char *)&diff64, 8);
if (!buf)
quit(1, "Failed to convert diff64 to buf in gen_stratum_work");
strcat((char *)work->target, buf);
free(buf);
applog(LOG_DEBUG, "Generated target %s", work->target);
}
static void get_work(struct work *work, struct thr_info *thr, const int thr_id)

1
util.c

@ -1255,6 +1255,7 @@ out: @@ -1255,6 +1255,7 @@ out:
if (ret) {
pool->stratum_active = true;
pool->swork.diff = 1;
if (opt_protocol) {
applog(LOG_DEBUG, "Pool %d confirmed mining.notify with subscription %s extranonce1 %s extran2size %d",
pool->pool_no, pool->subscription, pool->nonce1, pool->n2size);

Loading…
Cancel
Save