Browse Source

Announce and restart work immediately when current pool has caught up to the current block

Luke Dashjr 13 years ago
parent
commit
d530fa4634
1 changed files with 15 additions and 3 deletions
  1. 15 3
      cgminer.c

+ 15 - 3
cgminer.c

@@ -2591,17 +2591,29 @@ static void test_work_current(struct work *work)
 			applog(LOG_NOTICE, "New block detected on network");
 		restart_threads();
 	} else {
-		if (block_id == current_block_id)
+		bool restart = false;
+		struct pool *curpool = NULL;
+		if (unlikely(work->pool->block_id != block_id && block_id == current_block_id)) {
 			work->pool->block_id = block_id;
+			curpool = current_pool();
+			if (work->pool == curpool) {
+				applog(LOG_NOTICE, "%s %d caught up to new block",
+				       work->longpoll ? "LONGPOLL from pool" : "Pool",
+				       work->pool->pool_no);
+				restart = true;
+			}
+		}
 	  if (work->longpoll) {
 		work->longpoll = false;
 		++work->pool->work_restart_id;
-		if (work->pool == current_pool()) {
+		if ((!restart) && work->pool == current_pool()) {
 			applog(LOG_NOTICE, "LONGPOLL from pool %d requested work restart",
 				work->pool->pool_no);
-			restart_threads();
+			restart = true;
 		}
 	  }
+		if (restart)
+			restart_threads();
 	}
 out_free:
 	free(hexstr);