From 79e95dd95cefc1494313dd2832549387a33fb470 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 19 Feb 2012 22:15:55 +1100 Subject: [PATCH] Store whether a work item is the result of a longpoll or not in struct work and use it to help determine block changes directly from the work longpoll bool. --- cgminer.c | 13 ++++++++----- miner.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cgminer.c b/cgminer.c index e5b1e67b..91f89342 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1613,6 +1613,7 @@ retry: goto retry; } work->pool = pool; + work->longpoll = req_longpoll; total_getworks++; pool->getwork_requested++; @@ -2096,7 +2097,7 @@ static inline bool from_existing_block(struct work *work) return ret; } -static void test_work_current(struct work *work, bool longpoll) +static void test_work_current(struct work *work) { char *hexstr; @@ -2123,14 +2124,14 @@ static void test_work_current(struct work *work, bool longpoll) work_block++; - if (longpoll) + if (work->longpoll) applog(LOG_NOTICE, "LONGPOLL detected new block on network, waiting on fresh work"); else if (have_longpoll) applog(LOG_NOTICE, "New block detected on network before longpoll, waiting on fresh work"); else applog(LOG_NOTICE, "New block detected on network, waiting on fresh work"); restart_threads(); - } else if (longpoll) { + } else if (work->longpoll) { applog(LOG_NOTICE, "LONGPOLL requested work restart, waiting on fresh work"); work_block++; restart_threads(); @@ -2181,7 +2182,7 @@ static void *stage_thread(void *userdata) } work->work_block = work_block; - test_work_current(work, false); + test_work_current(work); applog(LOG_DEBUG, "Pushing work to getwork queue"); @@ -3484,11 +3485,13 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool) } work->pool = pool; work->rolltime = rolltime; + work->longpoll = true; + /* We'll be checking this work item twice, but we already know it's * from a new block so explicitly force the new block detection now * rather than waiting for it to hit the stage thread. This also * allows testwork to know whether LP discovered the block or not. */ - test_work_current(work, true); + test_work_current(work); work_clone = make_work(); memcpy(work_clone, work, sizeof(struct work)); diff --git a/miner.h b/miner.h index 0fce0bba..f75fe43e 100644 --- a/miner.h +++ b/miner.h @@ -574,6 +574,7 @@ struct work { bool clone; bool cloned; bool rolltime; + bool longpoll; unsigned int work_block; int id;