|
|
@ -1409,7 +1409,6 @@ static bool submit_upstream_work(const struct work *work) |
|
|
|
"{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}", |
|
|
|
"{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}", |
|
|
|
hexstr); |
|
|
|
hexstr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "DBG: sending %s submit RPC call: %s", pool->rpc_url, sd); |
|
|
|
applog(LOG_DEBUG, "DBG: sending %s submit RPC call: %s", pool->rpc_url, sd); |
|
|
|
|
|
|
|
|
|
|
|
/* Force a fresh connection in case there are dead persistent
|
|
|
|
/* Force a fresh connection in case there are dead persistent
|
|
|
@ -1451,7 +1450,6 @@ static bool submit_upstream_work(const struct work *work) |
|
|
|
pool->accepted++; |
|
|
|
pool->accepted++; |
|
|
|
cgpu->last_share_pool = pool->pool_no; |
|
|
|
cgpu->last_share_pool = pool->pool_no; |
|
|
|
cgpu->last_share_pool_time = time(NULL); |
|
|
|
cgpu->last_share_pool_time = time(NULL); |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)"); |
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: true (yay!!!)"); |
|
|
|
if (!QUIET) { |
|
|
|
if (!QUIET) { |
|
|
|
if (total_pools > 1) |
|
|
|
if (total_pools > 1) |
|
|
@ -1470,7 +1468,6 @@ static bool submit_upstream_work(const struct work *work) |
|
|
|
cgpu->rejected++; |
|
|
|
cgpu->rejected++; |
|
|
|
total_rejected++; |
|
|
|
total_rejected++; |
|
|
|
pool->rejected++; |
|
|
|
pool->rejected++; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)"); |
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)"); |
|
|
|
if (!QUIET) { |
|
|
|
if (!QUIET) { |
|
|
|
char where[17]; |
|
|
|
char where[17]; |
|
|
@ -1563,7 +1560,6 @@ static bool get_upstream_work(struct work *work, bool lagging) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pool = select_pool(lagging); |
|
|
|
pool = select_pool(lagging); |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req); |
|
|
|
applog(LOG_DEBUG, "DBG: sending %s get RPC call: %s", pool->rpc_url, rpc_req); |
|
|
|
|
|
|
|
|
|
|
|
retry: |
|
|
|
retry: |
|
|
@ -1670,19 +1666,16 @@ void kill_work(void) |
|
|
|
disable_curses(); |
|
|
|
disable_curses(); |
|
|
|
applog(LOG_INFO, "Received kill message"); |
|
|
|
applog(LOG_INFO, "Received kill message"); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off watchpool thread"); |
|
|
|
applog(LOG_DEBUG, "Killing off watchpool thread"); |
|
|
|
/* Kill the watchpool thread */ |
|
|
|
/* Kill the watchpool thread */ |
|
|
|
thr = &thr_info[watchpool_thr_id]; |
|
|
|
thr = &thr_info[watchpool_thr_id]; |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off watchdog thread"); |
|
|
|
applog(LOG_DEBUG, "Killing off watchdog thread"); |
|
|
|
/* Kill the watchdog thread */ |
|
|
|
/* Kill the watchdog thread */ |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
thr = &thr_info[watchdog_thr_id]; |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off mining threads"); |
|
|
|
applog(LOG_DEBUG, "Killing off mining threads"); |
|
|
|
/* Stop the mining threads*/ |
|
|
|
/* Stop the mining threads*/ |
|
|
|
for (i = 0; i < mining_threads; i++) { |
|
|
|
for (i = 0; i < mining_threads; i++) { |
|
|
@ -1690,19 +1683,16 @@ void kill_work(void) |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off stage thread"); |
|
|
|
applog(LOG_DEBUG, "Killing off stage thread"); |
|
|
|
/* Stop the others */ |
|
|
|
/* Stop the others */ |
|
|
|
thr = &thr_info[stage_thr_id]; |
|
|
|
thr = &thr_info[stage_thr_id]; |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off longpoll thread"); |
|
|
|
applog(LOG_DEBUG, "Killing off longpoll thread"); |
|
|
|
thr = &thr_info[longpoll_thr_id]; |
|
|
|
thr = &thr_info[longpoll_thr_id]; |
|
|
|
if (have_longpoll) |
|
|
|
if (have_longpoll) |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Killing off API thread"); |
|
|
|
applog(LOG_DEBUG, "Killing off API thread"); |
|
|
|
thr = &thr_info[api_thr_id]; |
|
|
|
thr = &thr_info[api_thr_id]; |
|
|
|
thr_info_cancel(thr); |
|
|
|
thr_info_cancel(thr); |
|
|
@ -1751,7 +1741,6 @@ static void *get_work_thread(void *userdata) |
|
|
|
} |
|
|
|
} |
|
|
|
fail_pause = opt_fail_pause; |
|
|
|
fail_pause = opt_fail_pause; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing work to requesting thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing work to requesting thread"); |
|
|
|
|
|
|
|
|
|
|
|
/* send work to requesting thread */ |
|
|
|
/* send work to requesting thread */ |
|
|
@ -1945,9 +1934,8 @@ static void discard_work(struct work *work) |
|
|
|
if (work->pool) |
|
|
|
if (work->pool) |
|
|
|
work->pool->discarded_work++; |
|
|
|
work->pool->discarded_work++; |
|
|
|
total_discarded++; |
|
|
|
total_discarded++; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Discarded work"); |
|
|
|
applog(LOG_DEBUG, "Discarded work"); |
|
|
|
} else if (opt_debug) |
|
|
|
} else |
|
|
|
applog(LOG_DEBUG, "Discarded cloned or rolled work"); |
|
|
|
applog(LOG_DEBUG, "Discarded cloned or rolled work"); |
|
|
|
free_work(work); |
|
|
|
free_work(work); |
|
|
|
} |
|
|
|
} |
|
|
@ -1996,7 +1984,6 @@ static int discard_stale(void) |
|
|
|
} |
|
|
|
} |
|
|
|
mutex_unlock(stgd_lock); |
|
|
|
mutex_unlock(stgd_lock); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Discarded %d stales that didn't match current hash", stale); |
|
|
|
applog(LOG_DEBUG, "Discarded %d stales that didn't match current hash", stale); |
|
|
|
|
|
|
|
|
|
|
|
/* Dec queued outside the loop to not have recursive locks */ |
|
|
|
/* Dec queued outside the loop to not have recursive locks */ |
|
|
@ -2146,7 +2133,6 @@ static void *stage_thread(void *userdata) |
|
|
|
while (ok) { |
|
|
|
while (ok) { |
|
|
|
struct work *work = NULL; |
|
|
|
struct work *work = NULL; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Popping work to stage thread"); |
|
|
|
applog(LOG_DEBUG, "Popping work to stage thread"); |
|
|
|
|
|
|
|
|
|
|
|
work = tq_pop(mythr->q, NULL); |
|
|
|
work = tq_pop(mythr->q, NULL); |
|
|
@ -2159,7 +2145,6 @@ static void *stage_thread(void *userdata) |
|
|
|
|
|
|
|
|
|
|
|
test_work_current(work, false); |
|
|
|
test_work_current(work, false); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing work to getwork queue"); |
|
|
|
applog(LOG_DEBUG, "Pushing work to getwork queue"); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!hash_push(work))) { |
|
|
|
if (unlikely(!hash_push(work))) { |
|
|
@ -2174,7 +2159,6 @@ static void *stage_thread(void *userdata) |
|
|
|
|
|
|
|
|
|
|
|
static bool stage_work(struct work *work) |
|
|
|
static bool stage_work(struct work *work) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing work to stage thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing work to stage thread"); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!tq_push(thr_info[stage_thr_id].q, work))) { |
|
|
|
if (unlikely(!tq_push(thr_info[stage_thr_id].q, work))) { |
|
|
@ -2738,7 +2722,6 @@ static void *workio_thread(void *userdata) |
|
|
|
while (ok) { |
|
|
|
while (ok) { |
|
|
|
struct workio_cmd *wc; |
|
|
|
struct workio_cmd *wc; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Popping work to work thread"); |
|
|
|
applog(LOG_DEBUG, "Popping work to work thread"); |
|
|
|
|
|
|
|
|
|
|
|
/* wait for workio_cmd sent to us, on our queue */ |
|
|
|
/* wait for workio_cmd sent to us, on our queue */ |
|
|
@ -2822,7 +2805,6 @@ static void hashmeter(int thr_id, struct timeval *diff, |
|
|
|
double thread_rolling = 0.0; |
|
|
|
double thread_rolling = 0.0; |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "[thread %d: %lu hashes, %.0f khash/sec]", |
|
|
|
applog(LOG_DEBUG, "[thread %d: %lu hashes, %.0f khash/sec]", |
|
|
|
thr_id, hashes_done, hashes_done / secs); |
|
|
|
thr_id, hashes_done, hashes_done / secs); |
|
|
|
|
|
|
|
|
|
|
@ -2927,7 +2909,6 @@ static bool pool_active(struct pool *pool, bool pinging) |
|
|
|
pool->pool_no, pool->rpc_url); |
|
|
|
pool->pool_no, pool->rpc_url); |
|
|
|
work->pool = pool; |
|
|
|
work->pool = pool; |
|
|
|
work->rolltime = rolltime; |
|
|
|
work->rolltime = rolltime; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing pooltest work to base pool"); |
|
|
|
applog(LOG_DEBUG, "Pushing pooltest work to base pool"); |
|
|
|
|
|
|
|
|
|
|
|
tq_push(thr_info[stage_thr_id].q, work); |
|
|
|
tq_push(thr_info[stage_thr_id].q, work); |
|
|
@ -3014,7 +2995,6 @@ static bool queue_request(struct thr_info *thr, bool needed) |
|
|
|
if (rq && needed && !requests_staged() && !opt_fail_only) |
|
|
|
if (rq && needed && !requests_staged() && !opt_fail_only) |
|
|
|
wc->lagging = true; |
|
|
|
wc->lagging = true; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Queueing getwork request to work thread"); |
|
|
|
applog(LOG_DEBUG, "Queueing getwork request to work thread"); |
|
|
|
|
|
|
|
|
|
|
|
/* send work request to workio thread */ |
|
|
|
/* send work request to workio thread */ |
|
|
@ -3074,7 +3054,6 @@ static void roll_work(struct work *work) |
|
|
|
local_work++; |
|
|
|
local_work++; |
|
|
|
work->rolls++; |
|
|
|
work->rolls++; |
|
|
|
work->blk.nonce = 0; |
|
|
|
work->blk.nonce = 0; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Successfully rolled work"); |
|
|
|
applog(LOG_DEBUG, "Successfully rolled work"); |
|
|
|
|
|
|
|
|
|
|
|
/* This is now a different work item so it needs a different ID for the
|
|
|
|
/* This is now a different work item so it needs a different ID for the
|
|
|
@ -3130,7 +3109,6 @@ retry: |
|
|
|
gettimeofday(&now, NULL); |
|
|
|
gettimeofday(&now, NULL); |
|
|
|
abstime.tv_sec = now.tv_sec + 60; |
|
|
|
abstime.tv_sec = now.tv_sec + 60; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Popping work from get queue to get work"); |
|
|
|
applog(LOG_DEBUG, "Popping work from get queue to get work"); |
|
|
|
|
|
|
|
|
|
|
|
/* wait for 1st response, or get cached response */ |
|
|
|
/* wait for 1st response, or get cached response */ |
|
|
@ -3159,7 +3137,6 @@ retry: |
|
|
|
|
|
|
|
|
|
|
|
/* Hand out a clone if we can roll this work item */ |
|
|
|
/* Hand out a clone if we can roll this work item */ |
|
|
|
if (reuse_work(work_heap)) { |
|
|
|
if (reuse_work(work_heap)) { |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing divided work to get queue head"); |
|
|
|
applog(LOG_DEBUG, "Pushing divided work to get queue head"); |
|
|
|
|
|
|
|
|
|
|
|
stage_work(work_heap); |
|
|
|
stage_work(work_heap); |
|
|
@ -3206,7 +3183,6 @@ bool submit_work_sync(struct thr_info *thr, const struct work *work_in) |
|
|
|
wc->thr = thr; |
|
|
|
wc->thr = thr; |
|
|
|
memcpy(wc->u.work, work_in, sizeof(*work_in)); |
|
|
|
memcpy(wc->u.work, work_in, sizeof(*work_in)); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing submit work to work thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing submit work to work thread"); |
|
|
|
|
|
|
|
|
|
|
|
/* send solution to workio thread */ |
|
|
|
/* send solution to workio thread */ |
|
|
@ -3295,7 +3271,6 @@ void *miner_thread(void *userdata) |
|
|
|
if (api->thread_init && !api->thread_init(mythr)) |
|
|
|
if (api->thread_init && !api->thread_init(mythr)) |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Popping ping in miner thread"); |
|
|
|
applog(LOG_DEBUG, "Popping ping in miner thread"); |
|
|
|
tq_pop(mythr->q, NULL); /* Wait for a ping to start */ |
|
|
|
tq_pop(mythr->q, NULL); /* Wait for a ping to start */ |
|
|
|
|
|
|
|
|
|
|
@ -3395,7 +3370,6 @@ void *miner_thread(void *userdata) |
|
|
|
if (unlikely(mythr->pause || !cgpu->enabled)) { |
|
|
|
if (unlikely(mythr->pause || !cgpu->enabled)) { |
|
|
|
applog(LOG_WARNING, "Thread %d being disabled", thr_id); |
|
|
|
applog(LOG_WARNING, "Thread %d being disabled", thr_id); |
|
|
|
mythr->rolling = mythr->cgpu->rolling = 0; |
|
|
|
mythr->rolling = mythr->cgpu->rolling = 0; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Popping wakeup ping in miner thread"); |
|
|
|
applog(LOG_DEBUG, "Popping wakeup ping in miner thread"); |
|
|
|
thread_reportout(mythr); |
|
|
|
thread_reportout(mythr); |
|
|
|
tq_pop(mythr->q, NULL); /* Ignore ping that's popped */ |
|
|
|
tq_pop(mythr->q, NULL); /* Ignore ping that's popped */ |
|
|
@ -3449,7 +3423,6 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool) |
|
|
|
memcpy(work_clone, work, sizeof(struct work)); |
|
|
|
memcpy(work_clone, work, sizeof(struct work)); |
|
|
|
while (reuse_work(work)) { |
|
|
|
while (reuse_work(work)) { |
|
|
|
work_clone->clone = true; |
|
|
|
work_clone->clone = true; |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing rolled converted work to stage thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing rolled converted work to stage thread"); |
|
|
|
if (unlikely(!stage_work(work_clone))) |
|
|
|
if (unlikely(!stage_work(work_clone))) |
|
|
|
break; |
|
|
|
break; |
|
|
@ -3458,12 +3431,11 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool) |
|
|
|
} |
|
|
|
} |
|
|
|
free_work(work_clone); |
|
|
|
free_work(work_clone); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing converted work to stage thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing converted work to stage thread"); |
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!stage_work(work))) |
|
|
|
if (unlikely(!stage_work(work))) |
|
|
|
free_work(work); |
|
|
|
free_work(work); |
|
|
|
else if (opt_debug) |
|
|
|
else |
|
|
|
applog(LOG_DEBUG, "Converted longpoll data to work"); |
|
|
|
applog(LOG_DEBUG, "Converted longpoll data to work"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3602,7 +3574,6 @@ static void start_longpoll(void) |
|
|
|
tq_thaw(thr->q); |
|
|
|
tq_thaw(thr->q); |
|
|
|
if (unlikely(thr_info_create(thr, NULL, longpoll_thread, thr))) |
|
|
|
if (unlikely(thr_info_create(thr, NULL, longpoll_thread, thr))) |
|
|
|
quit(1, "longpoll thread create failed"); |
|
|
|
quit(1, "longpoll thread create failed"); |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing ping to longpoll thread"); |
|
|
|
applog(LOG_DEBUG, "Pushing ping to longpoll thread"); |
|
|
|
tq_push(thr_info[longpoll_thr_id].q, &ping); |
|
|
|
tq_push(thr_info[longpoll_thr_id].q, &ping); |
|
|
|
} |
|
|
|
} |
|
|
@ -4471,7 +4442,6 @@ int main (int argc, char *argv[]) |
|
|
|
/* Enable threads for devices set not to mine but disable
|
|
|
|
/* Enable threads for devices set not to mine but disable
|
|
|
|
* their queue in case we wish to enable them later */ |
|
|
|
* their queue in case we wish to enable them later */ |
|
|
|
if (cgpu->enabled) { |
|
|
|
if (cgpu->enabled) { |
|
|
|
if (opt_debug) |
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Pushing ping to thread %d", thr->id); |
|
|
|
applog(LOG_DEBUG, "Pushing ping to thread %d", thr->id); |
|
|
|
|
|
|
|
|
|
|
|
tq_push(thr->q, &ping); |
|
|
|
tq_push(thr->q, &ping); |
|
|
|