From 512d2440948003555278f900eb15d6ce760fddfc Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 4 Oct 2012 08:52:56 +1000 Subject: [PATCH] Pass json error value to share result function to be able to parse reject reason in stratum. --- cgminer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cgminer.c b/cgminer.c index 49693158..c752517d 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1810,8 +1810,8 @@ static void reject_pool(struct pool *pool) * rejected values but the chance of two submits completing at the * same time is zero so there is no point adding extra locking */ static void -share_result(json_t *val, json_t *res, const struct work *work, char *hashshow, - bool resubmit, char *worktime) +share_result(json_t *val, json_t *res, json_t *err, const struct work *work, + char *hashshow, bool resubmit, char *worktime) { struct pool *pool = work->pool; struct cgpu_info *cgpu = thr_info[work->thr_id].cgpu; @@ -1917,7 +1917,7 @@ share_result(json_t *val, json_t *res, const struct work *work, char *hashshow, static bool submit_upstream_work(const struct work *work, CURL *curl, bool resubmit) { char *hexstr = NULL; - json_t *val, *res; + json_t *val, *res, *err; char s[345], sd[345]; bool rc = false; int thr_id = work->thr_id; @@ -1968,6 +1968,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no); res = json_object_get(val, "result"); + err = json_object_get(val, "error"); if (!QUIET) { hash32 = (uint32_t *)(work->hash); @@ -2022,7 +2023,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl, bool resub } } - share_result(val, res, work, hashshow, resubmit, worktime); + share_result(val, res, err, work, hashshow, resubmit, worktime); cgpu->utility = cgpu->accepted / total_secs * 60; @@ -4048,7 +4049,7 @@ out_unlock: } } -static void stratum_share_result(json_t *val, json_t *res_val, +static void stratum_share_result(json_t *val, json_t *res_val, json_t *err_val, struct stratum_share *sshare) { struct work *work = &sshare->work; @@ -4060,7 +4061,7 @@ static void stratum_share_result(json_t *val, json_t *res_val, 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, ""); + share_result(val, res_val, err_val, work, hashshow, false, ""); } /* Parses stratum json responses and tries to find the id that the request @@ -4112,7 +4113,7 @@ static bool parse_stratum_response(char *s) applog(LOG_NOTICE, "Rejected untracked stratum share"); goto out; } - stratum_share_result(val, res_val, sshare); + stratum_share_result(val, res_val, err_val, sshare); free(sshare); ret = true;