Browse Source

Build varint correctly for share submission and sleep 5 seconds before retrying submit.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
cb6f0340cd
  1. 36
      cgminer.c

36
cgminer.c

@ -2295,26 +2295,43 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
/* build JSON-RPC request */ /* build JSON-RPC request */
if (work->gbt) { 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) { if (work->gbt_txns < 0xfd) {
uint8_t val = work->gbt_txns; uint8_t val = work->gbt_txns;
sprintf(varint, "%02x", val); varint = bin2hex((const unsigned char *)&val, 1);
} else if (work->gbt_txns <= 0xffff) { } else if (work->gbt_txns <= 0xffff) {
uint16_t val = htole16(work->gbt_txns); uint16_t val = htole16(work->gbt_txns);
sprintf(varint, "fd%04x", val); strcat(gbt_block, "fd");
} else if ((unsigned int)work->gbt_txns <= 0xffffffff) { varint = bin2hex((const unsigned char *)&val, 2);
} else {
uint32_t val = htole32(work->gbt_txns); 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); applog(LOG_WARNING, "Varint %s", varint);
sprintf(gbt_block, "%s%s%s", header, varint, work->gbt_coinbase); strcat(gbt_block, varint);
free(header); 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 } else
sprintf(s, "{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}", hexstr); sprintf(s, "{\"method\": \"getwork\", \"params\": [ \"%s\" ], \"id\":1}", hexstr);
applog(LOG_WARNING, "DBG: sending %s submit RPC call: %s", pool->rpc_url, s); 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++; pool->remotefail_occasions++;
applog(LOG_WARNING, "Pool %d communication failure, caching submissions", pool->pool_no); applog(LOG_WARNING, "Pool %d communication failure, caching submissions", pool->pool_no);
} }
sleep(5);
goto out; goto out;
} else if (pool_tclear(pool, &pool->submit_fail)) } else if (pool_tclear(pool, &pool->submit_fail))
applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no); applog(LOG_WARNING, "Pool %d communication resumed, submitting work", pool->pool_no);

Loading…
Cancel
Save