Browse Source

Split block contents hiding/providing notices out from stratum code

Luke Dashjr 12 years ago
parent
commit
79739d34a1
2 changed files with 18 additions and 9 deletions
  1. 1 1
      libblkmaker
  2. 17 8
      miner.c

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 19847fbab02450fb0db2ae519a35808cdc091991
+Subproject commit 8f4bb3ee9f43405203fef6f64ca938dc7933a060

+ 17 - 8
miner.c

@@ -1758,6 +1758,21 @@ void have_block_height(uint32_t block_id, uint32_t blkheight)
 	mutex_unlock(&ch_lock);
 	mutex_unlock(&ch_lock);
 }
 }
 
 
+static
+void pool_set_opaque(struct pool *pool, bool opaque)
+{
+	if (pool->swork.opaque == opaque)
+		return;
+	
+	pool->swork.opaque = opaque;
+	if (opaque)
+		applog(LOG_WARNING, "Pool %u is hiding block contents from us",
+		       pool->pool_no);
+	else
+		applog(LOG_NOTICE, "Pool %u now providing block contents to us",
+		       pool->pool_no);
+}
+
 static bool work_decode(struct pool *pool, struct work *work, json_t *val)
 static bool work_decode(struct pool *pool, struct work *work, json_t *val)
 {
 {
 	json_t *res_val = json_object_get(val, "result");
 	json_t *res_val = json_object_get(val, "result");
@@ -5575,11 +5590,7 @@ bool parse_stratum_response(struct pool *pool, char *s)
 				// TODO: Check hashes match actual merkle links
 				// TODO: Check hashes match actual merkle links
 			}
 			}
 
 
-			if (pool->swork.opaque) {
-				pool->swork.opaque = false;
-				applog(LOG_NOTICE, "Pool %u now providing block contents to us",
-				       pool->pool_no);
-			}
+			pool_set_opaque(pool, false);
 			pool->swork.transparency_time = (time_t)-1;
 			pool->swork.transparency_time = (time_t)-1;
 
 
 fishy:
 fishy:
@@ -5860,9 +5871,7 @@ static void *stratum_thread(void *userdata)
 		if (pool->swork.transparency_time != (time_t)-1 && difftime(time(NULL), pool->swork.transparency_time) > 21.09375) {
 		if (pool->swork.transparency_time != (time_t)-1 && difftime(time(NULL), pool->swork.transparency_time) > 21.09375) {
 			// More than 4 timmills past since requested transactions
 			// More than 4 timmills past since requested transactions
 			pool->swork.transparency_time = (time_t)-1;
 			pool->swork.transparency_time = (time_t)-1;
-			pool->swork.opaque = true;
-			applog(LOG_WARNING, "Pool %u is hiding block contents from us",
-			       pool->pool_no);
+			pool_set_opaque(pool, true);
 		}
 		}
 	}
 	}