Browse Source

Display X-Reject-Reason, when provided

nfactor-troky
Luke Dashjr 13 years ago
parent
commit
f7a9897e13
  1. 26
      cgminer.c
  2. 9
      util.c

26
cgminer.c

@ -1418,12 +1418,30 @@ static bool submit_upstream_work(const struct work *work) @@ -1418,12 +1418,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);
}
}

9
util.c

@ -57,6 +57,7 @@ struct upload_buffer { @@ -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) @@ -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, @@ -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);

Loading…
Cancel
Save