From 255bab88fe2f11a0eddef8af760a5dca338c9c1e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 3 Oct 2014 00:07:43 +1000 Subject: [PATCH] Add a maximum diff option --- README | 3 +++ ckpool.conf | 1 + ckproxy.conf | 1 + src/ckpool.c | 1 + src/ckpool.h | 1 + src/stratifier.c | 2 ++ 6 files changed, 9 insertions(+) diff --git a/README b/README index 15d47c46..01f32aa1 100644 --- a/README +++ b/README @@ -252,4 +252,7 @@ and 3334 in proxy mode. "startdiff" : Starting diff that new clients are given. Default 42 +"maxdiff" : Optional maximum diff that vardiff will clamp to where zero is no +maximum. + "logdir" : Which directory to store pool and client logs. Default "logs" diff --git a/ckpool.conf b/ckpool.conf index 62424d30..340556bd 100644 --- a/ckpool.conf +++ b/ckpool.conf @@ -20,6 +20,7 @@ "serverurl" : "ckpool.org:3333", "mindiff" : 1, "startdiff" : 42, +"maxdiff" : 0, "logdir" : "logs" } Comments from here on are ignored. diff --git a/ckproxy.conf b/ckproxy.conf index b4e3f2bf..6754198b 100644 --- a/ckproxy.conf +++ b/ckproxy.conf @@ -15,6 +15,7 @@ "serverurl" : "192.168.1.100:3334", "mindiff" : 1, "startdiff" : 42, +"maxdiff" : 0, "logdir" : "logs" } Comments from here on are ignored. diff --git a/src/ckpool.c b/src/ckpool.c index dee10716..25dab571 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -983,6 +983,7 @@ static void parse_config(ckpool_t *ckp) json_get_string(&ckp->serverurl, json_conf, "serverurl"); json_get_int64(&ckp->mindiff, json_conf, "mindiff"); json_get_int64(&ckp->startdiff, json_conf, "startdiff"); + json_get_int64(&ckp->maxdiff, json_conf, "maxdiff"); json_get_string(&ckp->logdir, json_conf, "logdir"); arr_val = json_object_get(json_conf, "proxy"); if (arr_val && json_is_array(arr_val)) { diff --git a/src/ckpool.h b/src/ckpool.h index a29798d3..9e3311cb 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -150,6 +150,7 @@ struct ckpool_instance { /* Difficulty settings */ int64_t mindiff; // Default 1 int64_t startdiff; // Default 42 + int64_t maxdiff; // No default /* Coinbase data */ char *btcaddress; // Address to mine to diff --git a/src/stratifier.c b/src/stratifier.c index b33f7ab9..264352f9 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1838,6 +1838,8 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, int diff, bool optimal = client->suggest_diff; } else if (optimal < worker->mindiff) optimal = worker->mindiff; + if (ckp->maxdiff && optimal > ckp->maxdiff) + optimal = ckp->maxdiff; if (optimal > network_diff) optimal = network_diff; if (client->diff == optimal)