mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +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
34
cgminer.c
34
cgminer.c
@ -1919,7 +1919,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub
|
||||
int rolltime;
|
||||
uint32_t *hash32;
|
||||
struct timeval tv_submit, tv_submit_reply;
|
||||
char hashshow[64+1] = "";
|
||||
char hashshow[64 +1 ] = "";
|
||||
char worktime[200] = "";
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
@ -2757,6 +2757,8 @@ static void *submit_work_thread(void *userdata)
|
||||
pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
|
||||
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));
|
||||
|
||||
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
|
||||
* matched to and treat it accordingly. */
|
||||
static bool parse_stratum_response(char *s)
|
||||
@ -4042,7 +4059,7 @@ static bool parse_stratum_response(char *s)
|
||||
|
||||
val = JSON_LOADS(s, &err);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -4059,20 +4076,29 @@ static bool parse_stratum_response(char *s)
|
||||
else
|
||||
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);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
id = json_integer_value(id_val);
|
||||
mutex_lock(&sshare_lock);
|
||||
HASH_FIND_INT(stratum_shares, &id, sshare);
|
||||
if (sshare)
|
||||
HASH_DEL(stratum_shares, sshare);
|
||||
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;
|
||||
}
|
||||
stratum_share_result(val, res_val, sshare);
|
||||
free(sshare);
|
||||
|
||||
ret = true;
|
||||
out:
|
||||
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");
|
||||
if (!method)
|
||||
goto out;
|
||||
err_val = json_object_get(val, "error");
|
||||
params = json_object_get(val, "params");
|
||||
|
||||
if (!method || json_is_null(method) ||
|
||||
(err_val && !json_is_null(err_val))) {
|
||||
if (err_val && !json_is_null(err_val)) {
|
||||
char *ss;
|
||||
|
||||
if (err_val)
|
||||
@ -1077,7 +1078,7 @@ bool parse_method(struct pool *pool, char *s)
|
||||
else
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user