Skip to content

Commit

Permalink
pool_actively_desired: If we are the highest priority, workable pool …
Browse files Browse the repository at this point in the history
…for a given algorithm, we are needed
  • Loading branch information
luke-jr committed Nov 5, 2014
1 parent 8c4613f commit ad3c4c8
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -5395,6 +5395,9 @@ static bool pool_unworkable(const struct pool * const pool)
return false;
}

static struct pool *priority_pool(int);
static bool pool_unusable(struct pool *);

static
bool pool_actively_desired(const struct pool * const pool, const struct pool *cp)
{
Expand All @@ -5404,7 +5407,23 @@ bool pool_actively_desired(const struct pool * const pool, const struct pool *cp
return true;
if (!cp)
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
Expand Down Expand Up @@ -5469,8 +5488,6 @@ struct pool *select_balanced(struct pool *cp, struct mining_algorithm * const ma
return ret;
}

static struct pool *priority_pool(int choice);

static
struct pool *select_loadbalance(struct mining_algorithm * const malgo)
{
Expand Down Expand Up @@ -5547,8 +5564,6 @@ out: ;
return pool;
}

static bool pool_unusable(struct pool *pool);

static
struct pool *select_failover(struct mining_algorithm * const malgo)
{
Expand Down

0 comments on commit ad3c4c8

Please sign in to comment.