Browse Source

Only include block display lines for active goals

Luke Dashjr 11 years ago
parent
commit
72f1312715
1 changed files with 25 additions and 2 deletions
  1. 25 2
      miner.c

+ 25 - 2
miner.c

@@ -375,6 +375,7 @@ static char best_share[ALLOC_H2B_SHORTV] = "0";
 double best_diff = 0;
 double best_diff = 0;
 
 
 struct mining_goal_info *mining_goals;
 struct mining_goal_info *mining_goals;
+int active_goals = 1;
 
 
 
 
 int swork_id;
 int swork_id;
@@ -1033,7 +1034,7 @@ struct mining_goal_info *get_mining_goal(const char * const name)
 		HASH_SORT(mining_goals, mining_goals_name_cmp);
 		HASH_SORT(mining_goals, mining_goals_name_cmp);
 		
 		
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES
-		devcursor = 7 + HASH_COUNT(mining_goals);
+		devcursor = 7 + active_goals;
 		switch_logsize();
 		switch_logsize();
 #endif
 #endif
 	}
 	}
@@ -4332,14 +4333,32 @@ void update_block_display_line(const int blky, struct mining_goal_info *goal)
 	wclrtoeol(statuswin);
 	wclrtoeol(statuswin);
 }
 }
 
 
+static bool pool_actively_in_use(const struct pool *, const struct pool *);
+
 static
 static
 void update_block_display(void)
 void update_block_display(void)
 {
 {
 	struct mining_goal_info *goal, *tmpgoal;
 	struct mining_goal_info *goal, *tmpgoal;
-	int blky = 3;
+	int blky = 3, i, total_found_goals = 0;
 	HASH_ITER(hh, mining_goals, goal, tmpgoal)
 	HASH_ITER(hh, mining_goals, goal, tmpgoal)
 	{
 	{
+		for (i = 0; i < total_pools; ++i)
+		{
+			struct pool * const pool = pools[i];
+			if (pool->goal == goal && pool_actively_in_use(pool, NULL))
+				break;
+		}
+		if (i >= total_pools)
+			// no pools using this goal, so it's probably stale anyway
+			continue;
 		update_block_display_line(blky++, goal);
 		update_block_display_line(blky++, goal);
+		++total_found_goals;
+	}
+	if (total_found_goals != active_goals)
+	{
+		active_goals = total_found_goals;
+		devcursor = 7 + active_goals;
+		switch_logsize();
 	}
 	}
 }
 }
 
 
@@ -4679,6 +4698,7 @@ static void switch_logsize(void)
 		unlock_curses();
 		unlock_curses();
 	}
 	}
 	check_winsizes();
 	check_winsizes();
+	update_block_display();
 }
 }
 
 
 /* For mandatory printing when mutex is already locked */
 /* For mandatory printing when mutex is already locked */
@@ -6891,6 +6911,9 @@ void switch_pools(struct pool *selected)
 	pthread_cond_broadcast(&lp_cond);
 	pthread_cond_broadcast(&lp_cond);
 	mutex_unlock(&lp_lock);
 	mutex_unlock(&lp_lock);
 
 
+#ifdef HAVE_CURSES
+	update_block_display();
+#endif
 }
 }
 
 
 static void discard_work(struct work *work)
 static void discard_work(struct work *work)