Browse Source

icarus: Double-buffer work to solve nonces found before work change takes effect

Luke Dashjr 12 years ago
parent
commit
e573f7e891
2 changed files with 6 additions and 2 deletions
  1. 5 2
      driver-icarus.c
  2. 1 0
      icarus-common.h

+ 5 - 2
driver-icarus.c

@@ -811,6 +811,8 @@ struct work *icarus_process_worknonce(struct icarus_state *state, uint32_t *nonc
 	*nonce = be32toh(*nonce);
 	if (test_nonce(state->last_work, *nonce, false))
 		return state->last_work;
+	if (test_nonce(state->last2_work, *nonce, false))
+		return state->last2_work;
 	return NULL;
 }
 
@@ -874,8 +876,9 @@ no_job_start:
 static
 void icarus_transition_work(struct icarus_state *state, struct work *work)
 {
-	if (state->last_work)
-		free_work(state->last_work);
+	if (state->last2_work)
+		free_work(state->last2_work);
+	state->last2_work = state->last_work;
 	state->last_work = copy_work(work);
 }
 

+ 1 - 0
icarus-common.h

@@ -93,6 +93,7 @@ struct icarus_state {
 	struct timeval tv_workstart;
 	struct timeval tv_workfinish;
 	struct work *last_work;
+	struct work *last2_work;
 	bool changework;
 	bool identify;