mirror of
https://github.com/GOSTSec/sgminer
synced 2025-08-29 15:22:16 +00:00
Only add stratum share to database if we succeeded in submitting it, with a debug output saying it succeeded.
This commit is contained in:
parent
aa97e87a13
commit
cafe9aac54
22
cgminer.c
22
cgminer.c
@ -2915,34 +2915,32 @@ static void *submit_work_thread(void *userdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (work->stratum) {
|
if (work->stratum) {
|
||||||
struct stratum_share *sshare = calloc(sizeof(struct stratum_share), 1);
|
|
||||||
uint32_t *hash32 = (uint32_t *)work->hash, nonce;
|
uint32_t *hash32 = (uint32_t *)work->hash, nonce;
|
||||||
char *noncehex;
|
char *noncehex;
|
||||||
char s[1024];
|
char s[1024];
|
||||||
|
|
||||||
memcpy(&sshare->work, work, sizeof(struct work));
|
|
||||||
|
|
||||||
/* Give the stratum share a unique id */
|
/* Give the stratum share a unique id */
|
||||||
mutex_lock(&sshare_lock);
|
swork_id++;
|
||||||
sshare->id = swork_id++;
|
|
||||||
HASH_ADD_INT(stratum_shares, id, sshare);
|
|
||||||
mutex_unlock(&sshare_lock);
|
|
||||||
|
|
||||||
nonce = *((uint32_t *)(work->data + 76));
|
nonce = *((uint32_t *)(work->data + 76));
|
||||||
noncehex = bin2hex((const unsigned char *)&nonce, 4);
|
noncehex = bin2hex((const unsigned char *)&nonce, 4);
|
||||||
|
|
||||||
memset(s, 0, 1024);
|
memset(s, 0, 1024);
|
||||||
sprintf(s, "{\"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\": %d, \"method\": \"mining.submit\"}",
|
sprintf(s, "{\"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\": %d, \"method\": \"mining.submit\"}",
|
||||||
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
|
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, swork_id);
|
||||||
free(noncehex);
|
free(noncehex);
|
||||||
|
|
||||||
applog(LOG_INFO, "Submitting share %08lx to pool %d", (unsigned long)(hash32[6]), pool->pool_no);
|
applog(LOG_INFO, "Submitting share %08lx to pool %d", (unsigned long)(hash32[6]), pool->pool_no);
|
||||||
|
|
||||||
if (unlikely(!stratum_send(pool, s, strlen(s)))) {
|
if (likely(stratum_send(pool, s, strlen(s)))) {
|
||||||
|
struct stratum_share *sshare = calloc(sizeof(struct stratum_share), 1);
|
||||||
|
|
||||||
|
applog(LOG_DEBUG, "Successfully submitted, adding to stratum_shares db");
|
||||||
|
memcpy(&sshare->work, work, sizeof(struct work));
|
||||||
|
|
||||||
mutex_lock(&sshare_lock);
|
mutex_lock(&sshare_lock);
|
||||||
HASH_DEL(stratum_shares, sshare);
|
sshare->id = swork_id;
|
||||||
|
HASH_ADD_INT(stratum_shares, id, sshare);
|
||||||
mutex_unlock(&sshare_lock);
|
mutex_unlock(&sshare_lock);
|
||||||
free(sshare);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user