Browse Source

Store the proxy and subproxy id work is generated from

master
Con Kolivas 10 years ago
parent
commit
3b40b805bd
  1. 1
      src/ckpool.c
  2. 3
      src/ckpool.h
  3. 18
      src/stratifier.c

1
src/ckpool.c

@ -1165,7 +1165,6 @@ static void parse_config(ckpool_t *ckp)
if (arr_size) if (arr_size)
parse_proxies(ckp, arr_val, arr_size); parse_proxies(ckp, arr_val, arr_size);
} }
json_get_bool(&ckp->clientsvspeed, json_conf, "clientsvspeed");
json_decref(json_conf); json_decref(json_conf);
} }

3
src/ckpool.h

@ -148,9 +148,6 @@ struct ckpool_instance {
/* Are we running as a proxy */ /* Are we running as a proxy */
bool proxy; bool proxy;
/* Do we prefer more proxy clients over support for >5TH clients */
bool clientsvspeed;
/* Are we running without ckdb */ /* Are we running without ckdb */
bool standalone; bool standalone;

18
src/stratifier.c

@ -126,7 +126,9 @@ struct workbase {
char *logdir; char *logdir;
ckpool_t *ckp; ckpool_t *ckp;
bool proxy; bool proxy; /* This workbase is proxied work */
int proxyid; /* The id of the proxy the workbase is from */
int subproxyid; /* The id of the subproxy the worbase is from */
}; };
typedef struct workbase workbase_t; typedef struct workbase workbase_t;
@ -1077,21 +1079,12 @@ static void update_subscribe(ckpool_t *ckp, const char *cmd)
proxy->enonce1constlen = strlen(proxy->enonce1) / 2; proxy->enonce1constlen = strlen(proxy->enonce1) / 2;
hex2bin(proxy->enonce1bin, proxy->enonce1, proxy->enonce1constlen); hex2bin(proxy->enonce1bin, proxy->enonce1, proxy->enonce1constlen);
proxy->nonce2len = json_integer_value(json_object_get(val, "nonce2len")); proxy->nonce2len = json_integer_value(json_object_get(val, "nonce2len"));
if (ckp->clientsvspeed) {
if (proxy->nonce2len > 5)
proxy->enonce1varlen = 4;
else if (proxy->nonce2len > 3)
proxy->enonce1varlen = 2;
else
proxy->enonce1varlen = 1;
} else {
if (proxy->nonce2len > 7) if (proxy->nonce2len > 7)
proxy->enonce1varlen = 4; proxy->enonce1varlen = 4;
else if (proxy->nonce2len > 5) else if (proxy->nonce2len > 5)
proxy->enonce1varlen = 2; proxy->enonce1varlen = 2;
else else
proxy->enonce1varlen = 1; proxy->enonce1varlen = 1;
}
proxy->enonce2varlen = proxy->nonce2len - proxy->enonce1varlen; proxy->enonce2varlen = proxy->nonce2len - proxy->enonce1varlen;
ck_wunlock(&sdata->workbase_lock); ck_wunlock(&sdata->workbase_lock);
@ -1105,11 +1098,11 @@ static void update_notify(ckpool_t *ckp, const char *cmd)
{ {
bool new_block = false, clean; bool new_block = false, clean;
sdata_t *sdata = ckp->data; sdata_t *sdata = ckp->data;
int i, id = 0, subid = 0;
char header[228]; char header[228];
const char *buf; const char *buf;
proxy_t *proxy; proxy_t *proxy;
workbase_t *wb; workbase_t *wb;
int i, id = 0;
json_t *val; json_t *val;
if (unlikely(strlen(cmd) < 8)) { if (unlikely(strlen(cmd) < 8)) {
@ -1125,6 +1118,7 @@ static void update_notify(ckpool_t *ckp, const char *cmd)
return; return;
} }
json_get_int(&id, val, "proxy"); json_get_int(&id, val, "proxy");
json_get_int(&subid, val, "subproxy");
proxy = proxy_by_id(sdata, id); proxy = proxy_by_id(sdata, id);
if (unlikely(!proxy->subscribed)) { if (unlikely(!proxy->subscribed)) {
LOGNOTICE("No valid proxy %d subscription to update notify yet", id); LOGNOTICE("No valid proxy %d subscription to update notify yet", id);
@ -1147,6 +1141,8 @@ static void update_notify(ckpool_t *ckp, const char *cmd)
wb = ckzalloc(sizeof(workbase_t)); wb = ckzalloc(sizeof(workbase_t));
wb->ckp = ckp; wb->ckp = ckp;
wb->proxy = true; wb->proxy = true;
wb->proxyid = id;
wb->subproxyid = subid;
json_int64cpy(&wb->id, val, "jobid"); json_int64cpy(&wb->id, val, "jobid");
json_strcpy(wb->prevhash, val, "prevhash"); json_strcpy(wb->prevhash, val, "prevhash");

Loading…
Cancel
Save