Browse Source

Add support for custom extranonce1 lengths

master
Con Kolivas 10 years ago
parent
commit
ab91682e22
  1. 3
      README
  2. 1
      ckpool.conf
  3. 5
      src/ckpool.c
  4. 1
      src/ckpool.h
  5. 10
      src/stratifier.c

3
README

@ -240,6 +240,9 @@ 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
not set on a btcd.
'noncelength" : This is optional allowing the extranonce1 length to be chosen
from 2 to 8. Default 8
"update_interval" : This is the frequency that stratum updates are sent out to
miners and is set to 30 seconds by default to help perpetuate transactions for
the health of the bitcoin network.

1
ckpool.conf

@ -16,6 +16,7 @@
"btcaddress" : "14BMjogz69qe8hk9thyzbmR5pg34mVKB1e",
"btcsig" : "/mined by ck/",
"blockpoll" : 100,
"noncelength" : 8,
"update_interval" : 30,
"serverurl" : "ckpool.org:3333",
"mindiff" : 1,

5
src/ckpool.c

@ -1017,6 +1017,7 @@ static void parse_config(ckpool_t *ckp)
ckp->btcsig[38] = '\0';
}
json_get_int(&ckp->blockpoll, json_conf, "blockpoll");
json_get_int(&ckp->noncelength, json_conf, "noncelength");
json_get_int(&ckp->update_interval, json_conf, "update_interval");
json_get_string(&ckp->serverurl, json_conf, "serverurl");
json_get_int64(&ckp->mindiff, json_conf, "mindiff");
@ -1311,6 +1312,10 @@ int main(int argc, char **argv)
ckp.btcaddress = ckp.donaddress;
if (!ckp.blockpoll)
ckp.blockpoll = 100;
if (!ckp.noncelength)
ckp.noncelength = 8;
else if (ckp.noncelength < 2 || ckp.noncelength > 8)
quit(0, "Invalid noncelength %d specified, must be 2~8", ckp.noncelength);
if (!ckp.update_interval)
ckp.update_interval = 30;
if (!ckp.mindiff)

1
src/ckpool.h

@ -148,6 +148,7 @@ struct ckpool_instance {
char **btcdpass;
bool *btcdnotify;
int blockpoll; // How frequently in ms to poll bitcoind for block updates
int noncelength; // Extranonce1 length
/* Difficulty settings */
int64_t mindiff; // Default 1

10
src/stratifier.c

@ -410,9 +410,7 @@ static void generate_coinbase(ckpool_t *ckp, workbase_t *wb)
len = ser_number(wb->coinb1bin + ofs, now.tv_nsec);
ofs += len;
/* Leave enonce1/2varlen constant at 8 bytes for bitcoind sources */
wb->enonce1varlen = 8;
wb->enonce2varlen = 8;
wb->enonce1varlen = wb->enonce2varlen = ckp->noncelength;
wb->coinb1bin[ofs++] = wb->enonce1varlen + wb->enonce2varlen;
wb->coinb1len = ofs;
@ -1568,10 +1566,14 @@ static bool new_enonce1(stratum_instance_t *client)
sdata->enonce1u.u64++;
ret = true;
break;
case 7:
case 6:
case 5:
case 4:
sdata->enonce1u.u32++;
ret = true;
break;
case 3:
case 2:
for (i = 0; i < 65536; i++) {
sdata->enonce1u.u16++;
@ -1588,6 +1590,8 @@ static bool new_enonce1(stratum_instance_t *client)
break;
}
break;
default:
quit(0, "Invalid enonce1varlen %d", wb->enonce1varlen);
}
if (ret)
client->enonce1_64 = sdata->enonce1u.u64;

Loading…
Cancel
Save