Browse Source

Keep track of how many goals reference each mining algorithm

Luke Dashjr 11 years ago
parent
commit
1654709d68
2 changed files with 7 additions and 2 deletions
  1. 5 2
      miner.c
  2. 2 0
      miner.h

+ 5 - 2
miner.c

@@ -1002,11 +1002,14 @@ static void switch_logsize(void);
 #endif
 
 static
-void goal_set_malgo(struct mining_goal_info * const goal, const struct mining_algorithm * const malgo)
+void goal_set_malgo(struct mining_goal_info * const goal, struct mining_algorithm * const malgo)
 {
 	if (goal->malgo == malgo)
 		return;
 	
+	if (goal->malgo)
+		--goal->malgo->goal_refs;
+	++malgo->goal_refs;
 	goal->malgo = malgo;
 }
 
@@ -1825,7 +1828,7 @@ const char *goal_set(struct mining_goal_info * const goal, const char * const op
 	{
 		if (!newvalue)
 			return "Goal option 'malgo' requires a value (eg, SHA256d)";
-		const struct mining_algorithm *new_malgo;
+		struct mining_algorithm *new_malgo;
 		if (!(strcasecmp(newvalue, "SHA256d") && strcasecmp(newvalue, "SHA256") && strcasecmp(newvalue, "SHA2")))
 			new_malgo = &malgo_sha256d;
 #ifdef USE_SCRYPT

+ 2 - 0
miner.h

@@ -1132,6 +1132,8 @@ struct mining_algorithm {
 	
 	void (*hash_data_f)(void *digest, const void *data);
 	
+	int goal_refs;
+	
 	struct mining_algorithm *next;
 };