From 106d03882e4a83ef1f45ba45ec235364b96a7046 Mon Sep 17 00:00:00 2001 From: pooler Date: Mon, 5 May 2014 13:08:18 +0200 Subject: [PATCH] Avoid fetching too much work when LP is off --- cpu-miner.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index cf6d76c..f744211 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1024,11 +1024,12 @@ static void *miner_thread(void *userdata) if (work.data[19] >= end_nonce && !memcmp(work.data, g_work.data, 76)) stratum_gen_work(&stratum, &g_work); } else { + int min_scantime = have_longpoll ? LP_SCANTIME : opt_scantime; /* obtain new work from internal workio thread */ pthread_mutex_lock(&g_work_lock); - if (!have_stratum && (!have_longpoll || - time(NULL) >= g_work_time + LP_SCANTIME*3/4 || - work.data[19] >= end_nonce)) { + if (!have_stratum && + (time(NULL) - g_work_time >= min_scantime || + work.data[19] >= end_nonce)) { if (unlikely(!get_work(mythr, &g_work))) { applog(LOG_ERR, "work retrieval failed, exiting " "mining thread %d", mythr->id);