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) @@ -512,6 +512,7 @@ struct pool *add_pool(void)
pool->rpc_req = getwork_req;
pool->rpc_proxy = NULL;
pool->quota = 1;
return pool;
}
@ -697,19 +698,20 @@ bool detect_stratum(struct pool *pool, char *url) @@ -697,19 +698,20 @@ bool detect_stratum(struct pool *pool, char *url)
return false;
}
static char *set_url(char *arg)
static struct pool *add_url(void)
{
struct pool *pool;
total_urls++;
if (total_urls > total_pools)
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);
if (detect_stratum(pool, arg))
return NULL;
return;
opt_set_charp(arg, &pool->rpc_url);
if (strncmp(arg, "http://", 7) &&
@ -723,6 +725,39 @@ static char *set_url(char *arg) @@ -723,6 +725,39 @@ static char *set_url(char *arg)
strncat(httpinput, arg, 248);
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;
}
@ -1201,6 +1236,9 @@ static struct opt_table opt_config_table[] = { @@ -1201,6 +1236,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--quiet|-q",
opt_set_bool, &opt_quiet,
"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_set_bool, &opt_realquiet,
"Disable all output"),

1
miner.h

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

Loading…
Cancel
Save