Browse Source

Revert stale-on-arrival failsafe, since it ends up needing exceptions for everything

This reverts commits 2b7661d39aa50cba1fe64c9be17f8c2b3cd9f018, 24fafd0f582f71692ded7c7cf999cc3ff7e16156, and 2c1cd8d9b6d9487742254ce720e30245841a6c9b.
Luke Dashjr 13 years ago
parent
commit
ebef3d3810
3 changed files with 11 additions and 39 deletions
  1. 0 4
      api.c
  2. 11 34
      miner.c
  3. 0 1
      miner.h

+ 0 - 4
api.c

@@ -175,7 +175,6 @@ static const char *WAIT = "Waiting";
 static const char *DISABLED = "Disabled";
 static const char *ALIVE = "Alive";
 static const char *REJECTING = "Rejecting";
-static const char *STALE = "Stale";
 static const char *UNKNOWN = "Unknown";
 #define _DYNAMIC "D"
 #ifdef HAVE_OPENCL
@@ -1675,9 +1674,6 @@ static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
 			case POOL_REJECTING:
 				status = (char *)REJECTING;
 				break;
-			case POOL_STALE:
-				status = (char *)STALE;
-				break;
 			case POOL_ENABLED:
 				if (pool->idle)
 					status = (char *)DEAD;

+ 11 - 34
miner.c

@@ -1917,15 +1917,19 @@ static void enable_pool(struct pool *pool)
 	}
 }
 
-static void disable_pool2(struct pool *pool, enum pool_enable pe)
+static void disable_pool(struct pool *pool)
 {
 	if (pool->enabled == POOL_ENABLED)
 		enabled_pools--;
-	pool->enabled = pe;
+	pool->enabled = POOL_DISABLED;
 }
 
-#define disable_pool(pool)  disable_pool2(pool, POOL_DISABLED)
-#define  reject_pool(pool)  disable_pool2(pool, POOL_REJECTING)
+static void reject_pool(struct pool *pool)
+{
+	if (pool->enabled == POOL_ENABLED)
+		enabled_pools--;
+	pool->enabled = POOL_REJECTING;
+}
 
 static bool submit_upstream_work(const struct work *work, CURL *curl)
 {
@@ -2568,7 +2572,7 @@ static bool workio_get_work(struct workio_cmd *wc)
 	return true;
 }
 
-static bool stale_work3(struct work *work, bool share, bool failoveronly)
+static bool stale_work(struct work *work, bool share)
 {
 	struct timeval now;
 	time_t work_expiry;
@@ -2606,7 +2610,6 @@ static bool stale_work3(struct work *work, bool share, bool failoveronly)
 	} else {
 		/* If this work isn't for the latest Bitcoin block, it's stale */
 		/* But only care about the current pool if failover-only */
-		/* Note this intentionally uses the global option, not the param */
 		if (block_id != (opt_fail_only ? pool->block_id : current_block_id))
 		{
 			applog(LOG_DEBUG, "Work stale due to block mismatch (%08lx != %d ? %08lx : %08lx)", (long)block_id, (int)opt_fail_only, (long)pool->block_id, (long)current_block_id);
@@ -2643,14 +2646,13 @@ static bool stale_work3(struct work *work, bool share, bool failoveronly)
 
 	/* If the user only wants strict failover, any work from a pool other than
 	 * the current one is always considered stale */
-	if (failoveronly && !share && pool != current_pool() && !work->mandatory) {
+	if (opt_fail_only && !share && pool != current_pool() && !work->mandatory) {
 		applog(LOG_DEBUG, "Work stale due to fail only pool mismatch (pool %u vs %u)", pool->pool_no, current_pool()->pool_no);
 		return true;
 	}
 
 	return false;
 }
-#define stale_work(work, share)  stale_work3(work, share, opt_fail_only)
 
 static void check_solve(struct work *work)
 {
@@ -3186,26 +3188,6 @@ static void *stage_thread(void *userdata)
 
 		test_work_current(work);
 
-		struct pool *pool = work->pool;
-		if (stale_work3(work, false, false)) {
-			struct timeval now;
-			gettimeofday(&now, NULL);
-			if (work->tv_staged.tv_sec >= now.tv_sec - 2 && pool->enabled != POOL_REJECTING) {
-				// Only for freshly fetched work, disable the pool giving it to us stale
-				applog(LOG_WARNING, "Pool %u gave us stale-on-arrival work, disabling!", pool->pool_no);
-				disable_pool2(pool, POOL_STALE);
-				if (pool == current_pool())
-					switch_pools(NULL);
-			}
-			continue;
-		}
-
-		if (unlikely(pool->enabled == POOL_STALE)) {
-			applog(LOG_WARNING, "Stale pool %d no longer giving stale work, re-enabling!", pool->pool_no);
-			enable_pool(pool);
-			switch_pools(NULL);
-		}
-
 		applog(LOG_DEBUG, "Pushing work to getwork queue");
 
 		if (unlikely(!hash_push(work))) {
@@ -3550,9 +3532,6 @@ updated:
 			case POOL_REJECTING:
 				wlogprint("Rejecting ");
 				break;
-			case POOL_STALE:
-				wlogprint("Stale ");
-				break;
 		}
 		wlogprint("%s Priority %d: %s  User:%s\n",
 			pool->idle? "Dead" : "Alive",
@@ -4908,9 +4887,7 @@ static struct pool *select_longpoll_pool(struct pool *cp)
  */
 static void wait_lpcurrent(struct pool *pool)
 {
-	if (pool->enabled == POOL_REJECTING || pool_strategy == POOL_LOADBALANCE
-	 || pool->enabled == POOL_STALE
-	)
+	if (pool->enabled == POOL_REJECTING || pool_strategy == POOL_LOADBALANCE)
 		return;
 
 	while (pool != current_pool() && pool_strategy != POOL_LOADBALANCE) {

+ 0 - 1
miner.h

@@ -770,7 +770,6 @@ enum pool_enable {
 	POOL_DISABLED,
 	POOL_ENABLED,
 	POOL_REJECTING,
-	POOL_STALE,
 };
 
 struct pool {