Browse Source

Generate the coinbase for generation of stratum based work.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
1f6fe55152
  1. 27
      cgminer.c
  2. 1
      miner.h
  3. 2
      util.c

27
cgminer.c

@ -4265,6 +4265,28 @@ static struct work *clone_work(struct work *work)
return work; return work;
} }
static void gen_stratum_work(struct pool *pool, struct work *work)
{
char *coinbase, *nonce2;
int len;
mutex_lock(&pool->pool_lock);
len = strlen(pool->swork.coinbase1) +
strlen(pool->nonce1) +
pool->n2size +
strlen(pool->swork.coinbase2);
coinbase = alloca(len + 1);
sprintf(coinbase, "%s", pool->swork.coinbase1);
strcat(coinbase, pool->nonce1);
nonce2 = bin2hex((const unsigned char *)&pool->nonce2, pool->n2size);
pool->nonce2++;
strcat(coinbase, nonce2);
free(nonce2);
strcat(coinbase, pool->swork.coinbase2);
mutex_unlock(&pool->pool_lock);
applog(LOG_DEBUG, "Generated stratum coinbase %s", coinbase);
}
static void get_work(struct work *work, struct thr_info *thr, const int thr_id) static void get_work(struct work *work, struct thr_info *thr, const int thr_id)
{ {
struct timespec abstime = {0, 0}; struct timespec abstime = {0, 0};
@ -4284,6 +4306,11 @@ static void get_work(struct work *work, struct thr_info *thr, const int thr_id)
retry: retry:
pool = current_pool(); pool = current_pool();
if (pool->has_stratum) {
gen_stratum_work(pool, work);
goto out;
}
if (reuse_work(work)) if (reuse_work(work))
goto out; goto out;

1
miner.h

@ -837,6 +837,7 @@ struct pool {
struct sockaddr_in *server, client; struct sockaddr_in *server, client;
char *subscription; char *subscription;
char *nonce1; char *nonce1;
uint32_t nonce2;
int n2size; int n2size;
bool has_stratum; bool has_stratum;
bool stratum_active; bool stratum_active;

2
util.c

@ -1014,6 +1014,8 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->swork.merkle[i] = json_array_string(arr, i); pool->swork.merkle[i] = json_array_string(arr, i);
} }
pool->swork.merkles = merkles; pool->swork.merkles = merkles;
if (clean)
pool->nonce2 = 0;
mutex_unlock(&pool->pool_lock); mutex_unlock(&pool->pool_lock);
if (opt_protocol) { if (opt_protocol) {

Loading…
Cancel
Save