Build varint correctly for share submission and sleep 5 seconds before retrying submit.
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
diff --git a/cgminer.c b/cgminer.c
index 51f83b9..962e1f2 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2295,26 +2295,43 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
/* build JSON-RPC request */
if (work->gbt) {
- char gbt_block[512], varint[10] = "", *header;
+ char gbt_block[512], *varint, *header;
+ unsigned char data[80];
+ int i;
+
+ for (i = 0; i < 80 / 4; i++) {
+ uint32_t *src32, *dst32;
+
+ src32 = (uint32_t *)&work->data[i * 4];
+ dst32 = (uint32_t *)&data[i * 4];
+ *dst32 = swab32(*src32);
+ }
+ header = bin2hex(data, 80);
+ sprintf(gbt_block, "%s", header);
+ free(header);
+ applog(LOG_WARNING, "%d transactions", work->gbt_txns);
if (work->gbt_txns < 0xfd) {
uint8_t val = work->gbt_txns;
- sprintf(varint, "%02x", val);
+ varint = bin2hex((const unsigned char *)&val, 1);
} else if (work->gbt_txns <= 0xffff) {
uint16_t val = htole16(work->gbt_txns);
- sprintf(varint, "fd%04x", val);
- } else if ((unsigned int)work->gbt_txns <= 0xffffffff) {
+ strcat(gbt_block, "fd");
+ varint = bin2hex((const unsigned char *)&val, 2);
+ } else {
uint32_t val = htole32(work->gbt_txns);
- sprintf(varint, "fe%08x", val);
+ strcat(gbt_block, "fe");
+ varint = bin2hex((const unsigned char *)&val, 4);
}
- header = bin2hex(work->data, 80);
- sprintf(gbt_block, "%s%s%s", header, varint, work->gbt_coinbase);
- free(header);
+ applog(LOG_WARNING, "Varint %s", varint);
+ strcat(gbt_block, varint);
+ free(varint);
+ strcat(gbt_block, work->gbt_coinbase);
- sprintf(s, "{\"id\": 0, \"method\": \"submitblock\", \"params\": [\"%s\"]}", gbt_block);
+ sprintf(s, "{\"id\": 0, \"method\": \"submitblock\", \"params\": [\"%s\", {}]}", gbt_block);
} else
sprintf(s, "{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}", hexstr);
applog(LOG_WARNING, "DBG: sending %s submit RPC call: %s", pool->rpc_url, s);
@@ -2331,6 +2348,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
pool->remotefail_occasions++;
applog(LOG_WARNING, "Pool %d communication failure, caching submissions", pool->pool_no);
}
+ sleep(5);
goto out;
} else if (pool_tclear(pool, &pool->submit_fail))
applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no);