mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Generate the coinbase for generation of stratum based work.
This commit is contained in:
parent
1f64491f62
commit
1f6fe55152
27
cgminer.c
27
cgminer.c
@ -4265,6 +4265,28 @@ static struct work *clone_work(struct work *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)
|
||||
{
|
||||
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:
|
||||
pool = current_pool();
|
||||
|
||||
if (pool->has_stratum) {
|
||||
gen_stratum_work(pool, work);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (reuse_work(work))
|
||||
goto out;
|
||||
|
||||
|
1
miner.h
1
miner.h
@ -837,6 +837,7 @@ struct pool {
|
||||
struct sockaddr_in *server, client;
|
||||
char *subscription;
|
||||
char *nonce1;
|
||||
uint32_t nonce2;
|
||||
int n2size;
|
||||
bool has_stratum;
|
||||
bool stratum_active;
|
||||
|
Loading…
Reference in New Issue
Block a user