Provide a mechanism for setting a pool quota to be used by load-balance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/cgminer.c b/cgminer.c
index 892c6cf..d210520 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -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)
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)
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[] = {
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"),
diff --git a/miner.h b/miner.h
index d160406..8fd3f78 100644
--- a/miner.h
+++ b/miner.h
@@ -1120,6 +1120,7 @@ struct pool {
int solved;
int diff1;
char diff[8];
+ int quota;
double diff_accepted;
double diff_rejected;