Browse Source

Take into account average getwork delay as a marker of pool communications when considering work stale.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
c20a89d998
  1. 25
      cgminer.c

25
cgminer.c

@ -2158,25 +2158,34 @@ static bool workio_get_work(struct workio_cmd *wc) @@ -2158,25 +2158,34 @@ static bool workio_get_work(struct workio_cmd *wc)
static bool stale_work(struct work *work, bool share)
{
struct timeval now;
time_t work_expiry;
struct pool *pool;
int getwork_delay;
if (work->mandatory)
return false;
if (share)
work_expiry = opt_expiry;
else if (work->rolls)
work_expiry = work->rolltime;
else
work_expiry = opt_scantime;
pool = work->pool;
/* Factor in the average getwork delay of this pool, rounding it up to
* the nearest second */
getwork_delay = pool->cgminer_pool_stats.getwork_wait_rolling * 5 + 1;
work_expiry -= getwork_delay;
if (unlikely(work_expiry < 5))
work_expiry = 5;
gettimeofday(&now, NULL);
if (share) {
if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_expiry)
return true;
} else if (work->rolls) {
if ((now.tv_sec - work->tv_staged.tv_sec) >= work->rolltime)
return true;
} else if ((now.tv_sec - work->tv_staged.tv_sec) >= opt_scantime)
if ((now.tv_sec - work->tv_staged.tv_sec) >= work_expiry)
return true;
if (work->work_block != work_block)
return true;
pool = work->pool;
if (opt_fail_only && !share && pool != current_pool() && pool->enabled != POOL_REJECTING)
return true;

Loading…
Cancel
Save