Browse Source

bitmain: Get network difficulty from first work task

Possibly not robust for balancing strategies, but shouldn't matter anyway
Luke Dashjr 10 years ago
parent
commit
1124980b97
1 changed files with 7 additions and 6 deletions
  1. 7 6
      driver-bitmain.c

+ 7 - 6
driver-bitmain.c

@@ -713,7 +713,6 @@ static int bitmain_set_txtask(uint8_t * sendbuf,
 	int diff = 0;
 	unsigned int difftmp = 0;
 	unsigned int pooldiff = 0;
-	uint64_t netdifftmp = 0;
 	int netdiff = 0;
 	if (unlikely(!bm)) {
 		applog(LOG_WARNING, "bitmain_set_txtask bitmain_txtask_token is null");
@@ -774,6 +773,13 @@ static int bitmain_set_txtask(uint8_t * sendbuf,
 						break;
 					}
 				}
+				
+				struct work * const work = works[index];
+				const struct pool * const pool = work->pool;
+				const struct mining_goal_info * const goal = pool->goal;
+				for (uint64_t netdifftmp = goal->current_diff; netdifftmp > 0; netdifftmp >>= 1) {
+					++netdiff;
+				}
 			}
 
 			if(BITMAIN_TEST_PRINT_WORK) {
@@ -791,11 +797,6 @@ static int bitmain_set_txtask(uint8_t * sendbuf,
 		return 0;
 	}
 	
-	netdifftmp = current_diff;
-	while(netdifftmp > 0) {
-		netdifftmp = netdifftmp >> 1;
-		netdiff++;
-	}
 	datalen += 48*cursendcount;
 
 	bm->length = datalen-4;