Fix big endian problems with gbt submissions.
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
diff --git a/cgminer.c b/cgminer.c
index ea74951..0c84919 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3077,7 +3077,6 @@ static void print_status(int thr_id)
static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
{
- char *hexstr = NULL;
json_t *val, *res, *err;
char *s;
bool rc = false;
@@ -3093,11 +3092,6 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
cgpu = get_thr_cgpu(thr_id);
- endian_flip128(work->data, work->data);
-
- /* build hex string */
- hexstr = bin2hex(work->data, sizeof(work->data));
-
/* build JSON-RPC request */
if (work->gbt) {
char *gbt_block, *varint;
@@ -3142,9 +3136,17 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
s = realloc_strcat(s, "\"]}");
free(gbt_block);
} else {
+ unsigned char data[128];
+ char *hexstr;
+
+ endian_flip128(data, work->data);
+
+ /* build hex string */
+ hexstr = bin2hex(data, 128);
s = strdup("{\"method\": \"getwork\", \"params\": [ \"");
s = realloc_strcat(s, hexstr);
s = realloc_strcat(s, "\" ], \"id\":1}");
+ free(hexstr);
}
applog(LOG_DEBUG, "DBG: sending %s submit RPC call: %s", pool->rpc_url, s);
s = realloc_strcat(s, "\n");
@@ -3249,7 +3251,6 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
rc = true;
out:
- free(hexstr);
return rc;
}