Browse Source

Add an option to selectively enable/disable compression in passthrough modes

master
ckolivas 9 years ago
parent
commit
3a9f5a491e
  1. 4
      README
  2. 5
      ckpassthrough.conf
  3. 4
      src/ckpool.c
  4. 3
      src/ckpool.h
  5. 12
      src/generator.c

4
README

@ -265,6 +265,10 @@ new network blocks and is 100 by default. It is intended to be a backup only
for when the notifier is not set up and only polls if the "notify" field is for when the notifier is not set up and only polls if the "notify" field is
not set on a btcd. not set on a btcd.
"compress" : When running in a passthrough mode (redirector, passthrough, node),
should we gzip compress large packets. For passthroughs on a local network it
is recommended to disable this. Default is enabled.
"nonce1length" : This is optional allowing the extranonce1 length to be chosen "nonce1length" : This is optional allowing the extranonce1 length to be chosen
from 2 to 8. Default 4 from 2 to 8. Default 4

5
ckpassthrough.conf

@ -6,14 +6,11 @@
"pass" : "pass" "pass" : "pass"
} }
], ],
"update_interval" : 30,
"serverurl" : [ "serverurl" : [
"192.168.1.100:3334", "192.168.1.100:3334",
"127.0.0.1:3334" "127.0.0.1:3334"
], ],
"mindiff" : 1, "compress" : true,
"startdiff" : 42,
"maxdiff" : 0,
"logdir" : "logs" "logdir" : "logs"
} }
Comments from here on are ignored. Comments from here on are ignored.

4
src/ckpool.c

@ -1539,6 +1539,7 @@ static void parse_config(ckpool_t *ckp)
ckp->btcsig[38] = '\0'; ckp->btcsig[38] = '\0';
} }
json_get_int(&ckp->blockpoll, json_conf, "blockpoll"); json_get_int(&ckp->blockpoll, json_conf, "blockpoll");
json_get_bool(&ckp->compress, json_conf, "compress");
json_get_int(&ckp->nonce1length, json_conf, "nonce1length"); json_get_int(&ckp->nonce1length, json_conf, "nonce1length");
json_get_int(&ckp->nonce2length, json_conf, "nonce2length"); json_get_int(&ckp->nonce2length, json_conf, "nonce2length");
json_get_int(&ckp->update_interval, json_conf, "update_interval"); json_get_int(&ckp->update_interval, json_conf, "update_interval");
@ -1907,6 +1908,9 @@ int main(int argc, char **argv)
if (ret && errno != EEXIST) if (ret && errno != EEXIST)
quit(1, "Failed to make directory %s", ckp.socket_dir); quit(1, "Failed to make directory %s", ckp.socket_dir);
/* Set default on */
ckp.compress = true;
parse_config(&ckp); parse_config(&ckp);
/* Set defaults if not found in config file */ /* Set defaults if not found in config file */
if (!ckp.btcds) { if (!ckp.btcds) {

3
src/ckpool.h

@ -192,6 +192,9 @@ struct ckpool_instance {
/* Are we a redirecting passthrough */ /* Are we a redirecting passthrough */
bool redirector; bool redirector;
/* Should we compress large packets in passthrough modes */
bool compress;
/* Are we running as a proxy */ /* Are we running as a proxy */
bool proxy; bool proxy;

12
src/generator.c

@ -766,7 +766,7 @@ out:
} }
/* cs semaphore must be held */ /* cs semaphore must be held */
static bool passthrough_stratum(connsock_t *cs, proxy_instance_t *proxi) static bool passthrough_stratum(ckpool_t *ckp, connsock_t *cs, proxy_instance_t *proxi)
{ {
json_t *req, *val = NULL, *res_val, *err_val; json_t *req, *val = NULL, *res_val, *err_val;
bool res, ret = false; bool res, ret = false;
@ -774,7 +774,7 @@ static bool passthrough_stratum(connsock_t *cs, proxy_instance_t *proxi)
JSON_CPACK(req, "{ss,sb,s[s]}", JSON_CPACK(req, "{ss,sb,s[s]}",
"method", "mining.passthrough", "method", "mining.passthrough",
"gz", json_true(), "gz", ckp->compress,
"params", PACKAGE"/"VERSION); "params", PACKAGE"/"VERSION);
res = send_json_msg(cs, req); res = send_json_msg(cs, req);
json_decref(req); json_decref(req);
@ -812,7 +812,7 @@ out:
} }
/* cs semaphore must be held */ /* cs semaphore must be held */
static bool node_stratum(connsock_t *cs, proxy_instance_t *proxi) static bool node_stratum(ckpool_t *ckp, connsock_t *cs, proxy_instance_t *proxi)
{ {
json_t *req, *val = NULL, *res_val, *err_val; json_t *req, *val = NULL, *res_val, *err_val;
bool res, ret = false; bool res, ret = false;
@ -820,7 +820,7 @@ static bool node_stratum(connsock_t *cs, proxy_instance_t *proxi)
JSON_CPACK(req, "{ss,sb,s[s]}", JSON_CPACK(req, "{ss,sb,s[s]}",
"method", "mining.node", "method", "mining.node",
"gz", json_true(), "gz", ckp->compress,
"params", PACKAGE"/"VERSION); "params", PACKAGE"/"VERSION);
res = send_json_msg(cs, req); res = send_json_msg(cs, req);
@ -1855,7 +1855,7 @@ static bool proxy_alive(ckpool_t *ckp, proxy_instance_t *proxi, connsock_t *cs,
goto out; goto out;
} }
if (ckp->node) { if (ckp->node) {
if (!node_stratum(cs, proxi)) { if (!node_stratum(ckp, cs, proxi)) {
LOGWARNING("Failed initial node setup to %s:%s !", LOGWARNING("Failed initial node setup to %s:%s !",
cs->url, cs->port); cs->url, cs->port);
goto out; goto out;
@ -1864,7 +1864,7 @@ static bool proxy_alive(ckpool_t *ckp, proxy_instance_t *proxi, connsock_t *cs,
goto out; goto out;
} }
if (ckp->passthrough) { if (ckp->passthrough) {
if (!passthrough_stratum(cs, proxi)) { if (!passthrough_stratum(ckp, cs, proxi)) {
LOGWARNING("Failed initial passthrough to %s:%s !", LOGWARNING("Failed initial passthrough to %s:%s !",
cs->url, cs->port); cs->url, cs->port);
goto out; goto out;

Loading…
Cancel
Save