From 85230c270eb4503d0d0521e7e192b8f3a34c7025 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sun, 18 Jan 2015 09:24:30 +1100 Subject: [PATCH] Reset all best share counters after a block solve --- src/stratifier.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/stratifier.c b/src/stratifier.c index 14243316..c26eed6d 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1332,6 +1332,26 @@ static void reconnect_clients(sdata_t *sdata, const char *cmd) stratum_broadcast(sdata, json_msg); } +static void reset_bestshares(sdata_t *sdata) +{ + user_instance_t *instance, *tmpuser; + stratum_instance_t *client, *tmp; + + ck_rlock(&sdata->instance_lock); + HASH_ITER(hh, sdata->stratum_instances, client, tmp) { + client->best_diff = 0; + } + HASH_ITER(hh, sdata->user_instances, instance, tmpuser) { + worker_instance_t *worker; + + instance->best_diff = 0; + DL_FOREACH(instance->worker_instances, worker) { + worker->best_diff = 0; + } + } + ck_runlock(&sdata->instance_lock); +} + static void block_solve(ckpool_t *ckp, const char *blockhash) { ckmsg_t *block, *tmp, *found = NULL; @@ -1385,6 +1405,7 @@ static void block_solve(ckpool_t *ckp, const char *blockhash) free(msg); LOGWARNING("Solved and confirmed block %d", height); + reset_bestshares(sdata); } static void block_reject(sdata_t *sdata, const char *blockhash)