Browse Source

pool_actively_desired: If we are the highest priority, workable pool for a given algorithm, we are needed

Luke Dashjr 11 years ago
parent
commit
ad3c4c82eb
1 changed files with 20 additions and 5 deletions
  1. 20 5
      miner.c

+ 20 - 5
miner.c

@@ -5395,6 +5395,9 @@ static bool pool_unworkable(const struct pool * const pool)
 	return false;
 	return false;
 }
 }
 
 
+static struct pool *priority_pool(int);
+static bool pool_unusable(struct pool *);
+
 static
 static
 bool pool_actively_desired(const struct pool * const pool, const struct pool *cp)
 bool pool_actively_desired(const struct pool * const pool, const struct pool *cp)
 {
 {
@@ -5404,7 +5407,23 @@ bool pool_actively_desired(const struct pool * const pool, const struct pool *cp
 		return true;
 		return true;
 	if (!cp)
 	if (!cp)
 		cp = current_pool();
 		cp = current_pool();
-	return (pool == cp);
+	if (pool == cp)
+		return true;
+	
+	// If we are the highest priority, workable pool for a given algorithm, we are needed
+	struct mining_algorithm * const malgo = pool->goal->malgo;
+	for (int i = 0; i < total_pools; ++i)
+	{
+		struct pool * const other_pool = priority_pool(i);
+		if (other_pool == pool)
+			return true;
+		if (pool_unusable(other_pool))
+			continue;
+		if (other_pool->goal->malgo == malgo)
+			break;
+	}
+	
+	return false;
 }
 }
 
 
 static
 static
@@ -5469,8 +5488,6 @@ struct pool *select_balanced(struct pool *cp, struct mining_algorithm * const ma
 	return ret;
 	return ret;
 }
 }
 
 
-static struct pool *priority_pool(int choice);
-
 static
 static
 struct pool *select_loadbalance(struct mining_algorithm * const malgo)
 struct pool *select_loadbalance(struct mining_algorithm * const malgo)
 {
 {
@@ -5547,8 +5564,6 @@ out: ;
 	return pool;
 	return pool;
 }
 }
 
 
-static bool pool_unusable(struct pool *pool);
-
 static
 static
 struct pool *select_failover(struct mining_algorithm * const malgo)
 struct pool *select_failover(struct mining_algorithm * const malgo)
 {
 {