mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 14:58:01 +00:00
handle mining.set_extranonce method
This commit is contained in:
parent
897ca9fd4c
commit
aaaf387222
48
util.c
48
util.c
@ -1664,6 +1664,48 @@ static bool parse_diff(struct pool *pool, json_t *val)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool parse_extranonce(struct pool *pool, json_t *val)
|
||||
{
|
||||
char s[RBUFSIZE], *nonce1;
|
||||
int n2size;
|
||||
int id = json_integer_value(json_object_get(val, "id"));
|
||||
json_t *params = json_object_get(val, "params");
|
||||
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
nonce1 = json_array_string(params, 0);
|
||||
if (!nonce1) {
|
||||
// applog(LOG_INFO, "Failed to get nonce1 in ");
|
||||
return false;
|
||||
}
|
||||
n2size = json_integer_value(json_array_get(params, 1));
|
||||
if (!n2size) {
|
||||
// applog(LOG_INFO, "Failed to get n2size in ");
|
||||
free(nonce1);
|
||||
return false;
|
||||
}
|
||||
|
||||
cg_wlock(&pool->data_lock);
|
||||
pool->nonce1 = nonce1;
|
||||
pool->n1_len = strlen(nonce1) / 2;
|
||||
free(pool->nonce1bin);
|
||||
pool->nonce1bin = (unsigned char *)calloc(pool->n1_len, 1);
|
||||
if (unlikely(!pool->nonce1bin))
|
||||
quithere(1, "Failed to calloc pool->nonce1bin");
|
||||
hex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);
|
||||
pool->n2size = n2size;
|
||||
cg_wunlock(&pool->data_lock);
|
||||
|
||||
sprintf(s, "{\"id\": %d, \"result\": \"true\", \"error\": null}", id);
|
||||
if (!stratum_send(pool, s, strlen(s)))
|
||||
return false;
|
||||
|
||||
applog(LOG_NOTICE, "%s coin change requested", get_pool_name(pool));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void __suspend_stratum(struct pool *pool)
|
||||
{
|
||||
clear_sockbuf(pool);
|
||||
@ -1807,6 +1849,12 @@ bool parse_method(struct pool *pool, char *s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!strncasecmp(buf, "mining.set_extranonce", 21) && parse_extranonce(pool, val)) {
|
||||
ret = true;
|
||||
json_decref(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!strncasecmp(buf, "client.reconnect", 16) && parse_reconnect(pool, params)) {
|
||||
ret = true;
|
||||
json_decref(val);
|
||||
|
Loading…
Reference in New Issue
Block a user