Merge branch 'reject_reason' of https://github.com/luke-jr/cgminer into reject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/cgminer.c b/cgminer.c
index 5781391..71402f9 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1473,12 +1473,30 @@ static bool submit_upstream_work(const struct work *work)
if (opt_debug)
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)");
if (!QUIET) {
+ char wherebuf[17];
+ char *where = wherebuf;
+ char reasonbuf[32];
+ char *reason = reasonbuf;
+
if (total_pools > 1)
- applog(LOG_NOTICE, "Rejected %s %s %d thread %d pool %d",
- hashshow, cgpu->api->name, cgpu->device_id, thr_id, work->pool->pool_no);
+ sprintf(where, " pool %d", work->pool->pool_no);
else
- applog(LOG_NOTICE, "Rejected %s %s %d thread %d",
- hashshow, cgpu->api->name, cgpu->device_id, thr_id);
+ where = "";
+
+ res = json_object_get(val, "reject-reason");
+ if (res) {
+ const char *reasontmp = json_string_value(res);
+ size_t reasonLen = strlen(reasontmp);
+ if (reasonLen > 28)
+ reasonLen = 28;
+ reason[0] = ' '; reason[1] = '(';
+ memcpy(2 + reason, reasontmp, reasonLen);
+ reason[reasonLen + 2] = ')'; reason[reasonLen + 3] = '\0';
+ } else
+ reason = "";
+
+ applog(LOG_NOTICE, "Rejected %s %s %d thread %d%s%s",
+ hashshow, cgpu->api->name, cgpu->device_id, thr_id, where, reason);
}
}
diff --git a/util.c b/util.c
index 563a4d7..d3b65e5 100644
--- a/util.c
+++ b/util.c
@@ -57,6 +57,7 @@ struct upload_buffer {
struct header_info {
char *lp_path;
bool has_rolltime;
+ char *reason;
};
struct tq_ent {
@@ -232,6 +233,11 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
val = NULL;
}
+ if (!strcasecmp("X-Reject-Reason", key)) {
+ hi->reason = val; /* steal memory reference */
+ val = NULL;
+ }
+
out:
free(key);
free(val);
@@ -465,6 +471,9 @@ json_t *json_rpc_call(CURL *curl, const char *url,
goto err_out;
}
+ if (hi.reason)
+ json_object_set_new(val, "reject-reason", json_string(hi.reason));
+
successful_connect = true;
databuf_free(&all_data);
curl_slist_free_all(headers);