Skip to content

Instantly share code, notes, and snippets.

@kke
Created January 8, 2014 23:50
Show Gist options
  • Select an option

  • Save kke/8326956 to your computer and use it in GitHub Desktop.

Select an option

Save kke/8326956 to your computer and use it in GitHub Desktop.
static inline bool should_roll(struct work *work)
{
struct timeval now;
time_t expiry;
if (work->pool != current_pool() && pool_strategy != POOL_LOADBALANCE && pool_strategy != POOL_BALANCE)
return false;
if (work->rolltime > opt_scantime)
expiry = work->rolltime;
else
expiry = opt_scantime;
expiry = expiry * 2 / 3;
/* We shouldn't roll if we're unlikely to get one shares' duration
* work out of doing so */
cgtime(&now);
if (now.tv_sec - work->tv_staged.tv_sec > expiry)
return false;
return true;
}
/* Limit rolls to 7000 to not beyond 2 hours in the future where bitcoind will
* reject blocks as invalid. */
static inline bool can_roll(struct work *work)
{
return (!work->stratum && work->pool && work->rolltime && !work->clone &&
work->rolls < 7000 && !stale_work(work, false));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment