mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-04 11:04:26 +00:00
Submit shares from stratum through the abstracted submit share function detecting what message they belong to and showing the data from the associated work, and then deleting it from the hash.
This commit is contained in:
parent
fa4c9bf60f
commit
8baac0d66d
32
cgminer.c
32
cgminer.c
@ -2757,6 +2757,8 @@ static void *submit_work_thread(void *userdata)
|
|||||||
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
|
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
|
||||||
free(noncehex);
|
free(noncehex);
|
||||||
|
|
||||||
|
applog(LOG_INFO, "Submitting share %08lx to pool %d", (unsigned long)(hash32[6]), pool->pool_no);
|
||||||
|
|
||||||
sock_send(pool->sock, s, strlen(s));
|
sock_send(pool->sock, s, strlen(s));
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
@ -4030,6 +4032,21 @@ out_unlock:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void stratum_share_result(json_t *val, json_t *res_val,
|
||||||
|
struct stratum_share *sshare)
|
||||||
|
{
|
||||||
|
struct work *work = &sshare->work;
|
||||||
|
char hashshow[65];
|
||||||
|
uint32_t *hash32;
|
||||||
|
int intdiff;
|
||||||
|
|
||||||
|
hash32 = (uint32_t *)(work->hash);
|
||||||
|
intdiff = round(work->work_difficulty);
|
||||||
|
sprintf(hashshow, "%08lx Diff %d%s", (unsigned long)(hash32[6]), intdiff,
|
||||||
|
work->block? " BLOCK!" : "");
|
||||||
|
share_result(val, res_val, work, hashshow, false, "");
|
||||||
|
}
|
||||||
|
|
||||||
/* Parses stratum json responses and tries to find the id that the request
|
/* Parses stratum json responses and tries to find the id that the request
|
||||||
* matched to and treat it accordingly. */
|
* matched to and treat it accordingly. */
|
||||||
static bool parse_stratum_response(char *s)
|
static bool parse_stratum_response(char *s)
|
||||||
@ -4042,7 +4059,7 @@ static bool parse_stratum_response(char *s)
|
|||||||
|
|
||||||
val = JSON_LOADS(s, &err);
|
val = JSON_LOADS(s, &err);
|
||||||
if (!val) {
|
if (!val) {
|
||||||
applog(LOG_INFO, "JSON decode failed(%d): %s", err.line, err.text);;
|
applog(LOG_INFO, "JSON decode failed(%d): %s", err.line, err.text);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4059,20 +4076,29 @@ static bool parse_stratum_response(char *s)
|
|||||||
else
|
else
|
||||||
ss = strdup("(unknown reason)");
|
ss = strdup("(unknown reason)");
|
||||||
|
|
||||||
applog(LOG_INFO, "JSON-RPC decode failed: %s", ss);
|
applog(LOG_INFO, "JSON-RPC non method decode failed: %s", ss);
|
||||||
|
|
||||||
free(ss);
|
free(ss);
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = json_integer_value(id_val);
|
||||||
mutex_lock(&sshare_lock);
|
mutex_lock(&sshare_lock);
|
||||||
HASH_FIND_INT(stratum_shares, &id, sshare);
|
HASH_FIND_INT(stratum_shares, &id, sshare);
|
||||||
if (sshare)
|
if (sshare)
|
||||||
HASH_DEL(stratum_shares, sshare);
|
HASH_DEL(stratum_shares, sshare);
|
||||||
mutex_unlock(&sshare_lock);
|
mutex_unlock(&sshare_lock);
|
||||||
if (!sshare)
|
if (!sshare) {
|
||||||
|
if (json_is_true(res_val))
|
||||||
|
applog(LOG_NOTICE, "Accepted untracked stratum share");
|
||||||
|
else
|
||||||
|
applog(LOG_NOTICE, "Rejected untracked stratum share");
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
stratum_share_result(val, res_val, sshare);
|
||||||
|
free(sshare);
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
out:
|
out:
|
||||||
if (val)
|
if (val)
|
||||||
|
7
util.c
7
util.c
@ -1065,11 +1065,12 @@ bool parse_method(struct pool *pool, char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
method = json_object_get(val, "method");
|
method = json_object_get(val, "method");
|
||||||
|
if (!method)
|
||||||
|
goto out;
|
||||||
err_val = json_object_get(val, "error");
|
err_val = json_object_get(val, "error");
|
||||||
params = json_object_get(val, "params");
|
params = json_object_get(val, "params");
|
||||||
|
|
||||||
if (!method || json_is_null(method) ||
|
if (err_val && !json_is_null(err_val)) {
|
||||||
(err_val && !json_is_null(err_val))) {
|
|
||||||
char *ss;
|
char *ss;
|
||||||
|
|
||||||
if (err_val)
|
if (err_val)
|
||||||
@ -1077,7 +1078,7 @@ bool parse_method(struct pool *pool, char *s)
|
|||||||
else
|
else
|
||||||
ss = strdup("(unknown reason)");
|
ss = strdup("(unknown reason)");
|
||||||
|
|
||||||
applog(LOG_INFO, "JSON-RPC decode failed: %s", ss);
|
applog(LOG_INFO, "JSON-RPC method decode failed: %s", ss);
|
||||||
|
|
||||||
free(ss);
|
free(ss);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user