mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 15:27:53 +00:00
Check for the coinbase/append mutable in GBT support to decide whether to use it or not.
This commit is contained in:
parent
d10699d4c3
commit
26e0115030
36
cgminer.c
36
cgminer.c
@ -1359,15 +1359,14 @@ static void calc_midstate(struct work *work)
|
|||||||
|
|
||||||
static bool work_decode(struct pool *pool, struct work *work, json_t *val)
|
static bool work_decode(struct pool *pool, struct work *work, json_t *val)
|
||||||
{
|
{
|
||||||
|
json_t *res_val = json_object_get(val, "result");
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
json_t *res_val;
|
|
||||||
|
|
||||||
if (pool->has_gbt) {
|
if (pool->has_gbt) {
|
||||||
work->gbt = true;
|
work->gbt = true;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
res_val = json_object_get(val, "result");
|
|
||||||
if (unlikely(!jobj_binary(res_val, "data", work->data, sizeof(work->data), true))) {
|
if (unlikely(!jobj_binary(res_val, "data", work->data, sizeof(work->data), true))) {
|
||||||
applog(LOG_ERR, "JSON inval data");
|
applog(LOG_ERR, "JSON inval data");
|
||||||
goto out;
|
goto out;
|
||||||
@ -4455,13 +4454,36 @@ retry_stratum:
|
|||||||
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
|
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass,
|
||||||
gbt_req, true, false, &rolltime, pool, false);
|
gbt_req, true, false, &rolltime, pool, false);
|
||||||
if (val) {
|
if (val) {
|
||||||
pool->has_gbt = true;
|
json_t *res_val, *mutables;
|
||||||
pool->rpc_req = gbt_req;
|
int i, mutsize = 0;
|
||||||
applog(LOG_DEBUG, "GBT support found, switching to GBT protocol");
|
|
||||||
|
res_val = json_object_get(val, "result");
|
||||||
|
if (res_val) {
|
||||||
|
mutables = json_object_get(res_val, "mutable");
|
||||||
|
mutsize = json_array_size(mutables);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < mutsize; i++) {
|
||||||
|
json_t *arrval = json_array_get(mutables, i);
|
||||||
|
|
||||||
|
if (json_is_string(arrval)) {
|
||||||
|
const char *mutable = json_string_value(arrval);
|
||||||
|
|
||||||
|
/* Only use GBT if it supports coinbase append */
|
||||||
|
if (!strncasecmp(mutable, "coinbase/append", 15)) {
|
||||||
|
pool->has_gbt = true;
|
||||||
|
pool->rpc_req = gbt_req;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
json_decref(val);
|
json_decref(val);
|
||||||
} else
|
}
|
||||||
applog(LOG_DEBUG, "No GBT support found, using getwork protocol");
|
|
||||||
pool->probed = false;
|
pool->probed = false;
|
||||||
|
if (pool->has_gbt)
|
||||||
|
applog(LOG_DEBUG, "GBT coinbase append support found, switching to GBT protocol");
|
||||||
|
else
|
||||||
|
applog(LOG_DEBUG, "No GBT coinbase append support found, using getwork protocol");
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&tv_getwork, NULL);
|
gettimeofday(&tv_getwork, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user