Skip to content

Commit

Permalink
Keep track of how many goals reference each mining algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Nov 5, 2014
1 parent 80ebc83 commit 1654709
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions miner.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions miner.h
Expand Up @@ -1132,6 +1132,8 @@ struct mining_algorithm {

void (*hash_data_f)(void *digest, const void *data);

int goal_refs;

struct mining_algorithm *next;
};

Expand Down

0 comments on commit 1654709

Please sign in to comment.