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.
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 74
diff --git a/cgminer.c b/cgminer.c
index e5b1e67..91f8934 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 0fce0bb..f75fe43 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;