|
|
|
@ -32,6 +32,7 @@
@@ -32,6 +32,7 @@
|
|
|
|
|
#include <jansson.h> |
|
|
|
|
#include <curl/curl.h> |
|
|
|
|
#include <libgen.h> |
|
|
|
|
#include <openssl/sha.h> |
|
|
|
|
|
|
|
|
|
#include "compat.h" |
|
|
|
|
#include "miner.h" |
|
|
|
@ -2004,6 +2005,22 @@ void clear_logwin(void)
@@ -2004,6 +2005,22 @@ void clear_logwin(void)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* regenerate the full work->hash value */ |
|
|
|
|
void regeneratehash(const struct work *work) |
|
|
|
|
{ |
|
|
|
|
uint32_t *data32 = (uint32_t *)(work->data); |
|
|
|
|
unsigned char swap[128]; |
|
|
|
|
uint32_t *swap32 = (uint32_t *)swap; |
|
|
|
|
unsigned char hash1[SHA256_DIGEST_LENGTH]; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < 80/4; i++) |
|
|
|
|
swap32[i] = swab32(data32[i]); |
|
|
|
|
|
|
|
|
|
SHA256(swap, 80, hash1); |
|
|
|
|
SHA256(hash1, SHA256_DIGEST_LENGTH, (unsigned char *)(work->hash)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool submit_upstream_work(const struct work *work) |
|
|
|
|
{ |
|
|
|
|
char *hexstr = NULL; |
|
|
|
@ -2015,6 +2032,8 @@ static bool submit_upstream_work(const struct work *work)
@@ -2015,6 +2032,8 @@ static bool submit_upstream_work(const struct work *work)
|
|
|
|
|
CURL *curl = curl_easy_init(); |
|
|
|
|
struct pool *pool = work->pool; |
|
|
|
|
bool rolltime; |
|
|
|
|
uint32_t *hash32; |
|
|
|
|
char hashshow[32+1] = ""; |
|
|
|
|
|
|
|
|
|
if (unlikely(!curl)) { |
|
|
|
|
applog(LOG_ERR, "CURL initialisation failed"); |
|
|
|
@ -2054,6 +2073,14 @@ static bool submit_upstream_work(const struct work *work)
@@ -2054,6 +2073,14 @@ static bool submit_upstream_work(const struct work *work)
|
|
|
|
|
|
|
|
|
|
res = json_object_get(val, "result"); |
|
|
|
|
|
|
|
|
|
if (!QUIET) { |
|
|
|
|
regeneratehash(work); |
|
|
|
|
hash32 = (uint32_t *)(work->hash); |
|
|
|
|
sprintf(hashshow, "%08lx%08lx%08lx%08lx", |
|
|
|
|
(unsigned long)(hash32[7]), (unsigned long)(hash32[6]), |
|
|
|
|
(unsigned long)(hash32[5]), (unsigned long)(hash32[4])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Theoretically threads could race when modifying accepted and
|
|
|
|
|
* rejected values but the chance of two submits completing at the |
|
|
|
|
* same time is zero so there is no point adding extra locking */ |
|
|
|
@ -2065,11 +2092,11 @@ static bool submit_upstream_work(const struct work *work)
@@ -2065,11 +2092,11 @@ static bool submit_upstream_work(const struct work *work)
|
|
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)"); |
|
|
|
|
if (!QUIET) { |
|
|
|
|
if (total_pools > 1) |
|
|
|
|
applog(LOG_NOTICE, "Accepted %.8s %sPU %d thread %d pool %d", |
|
|
|
|
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no); |
|
|
|
|
applog(LOG_NOTICE, "Accepted %.32s %sPU %d thread %d pool %d", |
|
|
|
|
hashshow, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no); |
|
|
|
|
else |
|
|
|
|
applog(LOG_NOTICE, "Accepted %.8s %sPU %d thread %d", |
|
|
|
|
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id); |
|
|
|
|
applog(LOG_NOTICE, "Accepted %.32s %sPU %d thread %d", |
|
|
|
|
hashshow, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id); |
|
|
|
|
} |
|
|
|
|
if (opt_shares && total_accepted >= opt_shares) { |
|
|
|
|
applog(LOG_WARNING, "Successfully mined %d accepted shares as requested and exiting.", opt_shares); |
|
|
|
@ -2084,11 +2111,11 @@ static bool submit_upstream_work(const struct work *work)
@@ -2084,11 +2111,11 @@ static bool submit_upstream_work(const struct work *work)
|
|
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)"); |
|
|
|
|
if (!QUIET) { |
|
|
|
|
if (total_pools > 1) |
|
|
|
|
applog(LOG_NOTICE, "Rejected %.8s %sPU %d thread %d pool %d", |
|
|
|
|
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no); |
|
|
|
|
applog(LOG_NOTICE, "Rejected %.32s %sPU %d thread %d pool %d", |
|
|
|
|
hashshow, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id, work->pool->pool_no); |
|
|
|
|
else |
|
|
|
|
applog(LOG_NOTICE, "Rejected %.8s %sPU %d thread %d", |
|
|
|
|
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id); |
|
|
|
|
applog(LOG_NOTICE, "Rejected %.32s %sPU %d thread %d", |
|
|
|
|
hashshow, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|