Browse Source

Provide a mechanism for setting a pool quota to be used by load-balance.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
0121b75a4e
  1. 48
      cgminer.c
  2. 1
      miner.h

48
cgminer.c

@ -512,6 +512,7 @@ struct pool *add_pool(void)
pool->rpc_req = getwork_req; pool->rpc_req = getwork_req;
pool->rpc_proxy = NULL; pool->rpc_proxy = NULL;
pool->quota = 1;
return pool; return pool;
} }
@ -697,19 +698,20 @@ bool detect_stratum(struct pool *pool, char *url)
return false; return false;
} }
static char *set_url(char *arg) static struct pool *add_url(void)
{ {
struct pool *pool;
total_urls++; total_urls++;
if (total_urls > total_pools) if (total_urls > total_pools)
add_pool(); add_pool();
pool = pools[total_urls - 1]; return pools[total_urls - 1];
}
static void setup_url(struct pool *pool, char *arg)
{
arg = get_proxy(arg, pool); arg = get_proxy(arg, pool);
if (detect_stratum(pool, arg)) if (detect_stratum(pool, arg))
return NULL; return;
opt_set_charp(arg, &pool->rpc_url); opt_set_charp(arg, &pool->rpc_url);
if (strncmp(arg, "http://", 7) && if (strncmp(arg, "http://", 7) &&
@ -723,6 +725,39 @@ static char *set_url(char *arg)
strncat(httpinput, arg, 248); strncat(httpinput, arg, 248);
pool->rpc_url = httpinput; pool->rpc_url = httpinput;
} }
}
static char *set_url(char *arg)
{
struct pool *pool = add_url();
setup_url(pool, arg);
return NULL;
}
static char *set_quota(char *arg)
{
char *semicolon = strchr(arg, ';'), *url;
int len, qlen, quota;
struct pool *pool;
if (!semicolon)
return "No semicolon separated quota;URL pair found";
len = strlen(arg);
*semicolon = '\0';
qlen = strlen(arg);
if (!qlen)
return "No parameter for quota found";
len -= qlen + 1;
if (len < 1)
return "No parameter for URL found";
quota = atoi(arg);
if (quota < 0)
return "Invalid negative parameter for quota set";
url = arg + qlen + 1;
pool = add_url();
setup_url(pool, url);
pool->quota = quota;
return NULL; return NULL;
} }
@ -1201,6 +1236,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--quiet|-q", OPT_WITHOUT_ARG("--quiet|-q",
opt_set_bool, &opt_quiet, opt_set_bool, &opt_quiet,
"Disable logging output, display status and errors"), "Disable logging output, display status and errors"),
OPT_WITH_ARG("--quota|-U",
set_quota, NULL, NULL,
"quota;URL combination for server with load-balance strategy quotas"),
OPT_WITHOUT_ARG("--real-quiet", OPT_WITHOUT_ARG("--real-quiet",
opt_set_bool, &opt_realquiet, opt_set_bool, &opt_realquiet,
"Disable all output"), "Disable all output"),

1
miner.h

@ -1120,6 +1120,7 @@ struct pool {
int solved; int solved;
int diff1; int diff1;
char diff[8]; char diff[8];
int quota;
double diff_accepted; double diff_accepted;
double diff_rejected; double diff_rejected;

Loading…
Cancel
Save