mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-10 04:31:03 +00:00
Instead of keeping track of when the last work item was generated to keep stratum connections open, keep them open if any shares have been submitted awaiting a response.
This commit is contained in:
parent
82fce46633
commit
386ea2dffb
14
cgminer.c
14
cgminer.c
@ -3264,6 +3264,7 @@ static void *submit_work_thread(void *userdata)
|
||||
applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no);
|
||||
mutex_lock(&sshare_lock);
|
||||
HASH_ADD_INT(stratum_shares, id, sshare);
|
||||
pool->sshares++;
|
||||
mutex_unlock(&sshare_lock);
|
||||
applog(LOG_DEBUG, "Successfully submitted, adding to stratum_shares db");
|
||||
submitted = true;
|
||||
@ -3749,7 +3750,6 @@ static void stage_work(struct work *work)
|
||||
{
|
||||
applog(LOG_DEBUG, "Pushing work from pool %d to hash queue", work->pool->pool_no);
|
||||
work->work_block = work_block;
|
||||
work->pool->last_work_time = time(NULL);
|
||||
test_work_current(work);
|
||||
hash_push(work);
|
||||
}
|
||||
@ -4704,8 +4704,10 @@ static bool parse_stratum_response(struct pool *pool, char *s)
|
||||
id = json_integer_value(id_val);
|
||||
mutex_lock(&sshare_lock);
|
||||
HASH_FIND_INT(stratum_shares, &id, sshare);
|
||||
if (sshare)
|
||||
if (sshare) {
|
||||
HASH_DEL(stratum_shares, sshare);
|
||||
pool->sshares--;
|
||||
}
|
||||
mutex_unlock(&sshare_lock);
|
||||
if (!sshare) {
|
||||
if (json_is_true(res_val))
|
||||
@ -4738,6 +4740,7 @@ void clear_stratum_shares(struct pool *pool)
|
||||
HASH_DEL(stratum_shares, sshare);
|
||||
diff_cleared += sshare->work->work_difficulty;
|
||||
free_work(sshare->work);
|
||||
pool->sshares--;
|
||||
free(sshare);
|
||||
cleared++;
|
||||
}
|
||||
@ -4792,9 +4795,9 @@ static bool cnx_needed(struct pool *pool)
|
||||
return true;
|
||||
if (!cp->has_gbt && !cp->has_stratum && (!opt_fail_only || !cp->hdr_path))
|
||||
return true;
|
||||
/* Keep the connection open to allow any stray shares to be submitted
|
||||
* on switching pools for 2 minutes. */
|
||||
if (time(NULL) < pool->last_work_time + 120)
|
||||
/* If we're waiting for a response from shares submitted, keep the
|
||||
* connection open. */
|
||||
if (pool->sshares)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -5181,7 +5184,6 @@ static struct work *hash_pop(void)
|
||||
/* Signal hash_pop again in case there are mutliple hash_pop waiters */
|
||||
pthread_cond_signal(&getq->cond);
|
||||
mutex_unlock(stgd_lock);
|
||||
work->pool->last_work_time = time(NULL);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
2
miner.h
2
miner.h
@ -972,7 +972,6 @@ struct pool {
|
||||
pthread_cond_t cr_cond;
|
||||
struct list_head curlring;
|
||||
|
||||
time_t last_work_time;
|
||||
time_t last_share_time;
|
||||
double last_share_diff;
|
||||
uint64_t best_diff;
|
||||
@ -1000,6 +999,7 @@ struct pool {
|
||||
struct stratum_work swork;
|
||||
pthread_t stratum_thread;
|
||||
pthread_mutex_t stratum_lock;
|
||||
int sshares; /* stratum shares submitted waiting on response */
|
||||
|
||||
/* GBT variables */
|
||||
bool has_gbt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user