Commit 26a8a8e2c67b012ce929ee6577fab3ab70427c3b

Con Kolivas 2013-09-08T10:09:26

Use the --failover-only flag to have special meaning in combination with load-balance mode to distribute any unused quota back to pool 0 to maintain ratios amongst other pools.

diff --git a/README b/README
index 65c35e9..0abac0d 100644
--- a/README
+++ b/README
@@ -516,6 +516,11 @@ looking, so if the quota is changed on the fly, it only affects future work.
 If all pools are set to zero quota or all pools with quota are dead, it will
 fall back to a failover mode. See quota below for more information.
 
+The failover-only flag has special meaning in combination with load-balance
+mode and it will distribute quota back to pool 0 from any pools that are
+unable to provide work for any reason so as to maintain quota ratios between
+the rest of the pools.
+
 BALANCE:
 This strategy monitors the amount of difficulty 1 shares solved for each pool
 and uses it to try to end up doing the same amount of work for all pools.
diff --git a/cgminer.c b/cgminer.c
index ddf713b..54e1db7 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2843,8 +2843,14 @@ static inline struct pool *select_pool(bool lagging)
 		if (pool->quota_used++ >= pool->quota) {
 			pool->quota_used = 0;
 			pool = NULL;
-		} else if (!pool_unworkable(pool))
-			break;
+		} else {
+			if (!pool_unworkable(pool))
+				break;
+			/* Failover-only flag for load-balance means distribute
+			 * unused quota to pool 0. */
+			if (opt_fail_only)
+				pools[0]->quota++;
+		}
 		pool = NULL;
 		if (++rotating_pool >= total_pools)
 			rotating_pool = 0;