Browse Source

subscribe for mining.extranonce

idlebug
elbandi 11 years ago
parent
commit
b742ced4eb
  1. 11
      sgminer.c
  2. 18
      util.c

11
sgminer.c

@ -5204,6 +5204,15 @@ static bool parse_stratum_response(struct pool *pool, char *s)
id = json_integer_value(id_val); id = json_integer_value(id_val);
if (err_val && !json_is_null(err_val)) {
char *ss;
ss = (char *)json_string_value(json_array_get(err_val, 1));
if (strcmp(ss, "Method 'subscribe' not found for service 'mining.extranonce'") == 0) {
applog(LOG_INFO, "Cannot subscribe to mining.extranonce on %s", get_pool_name(pool));
goto out;
}
}
mutex_lock(&sshare_lock); mutex_lock(&sshare_lock);
HASH_FIND_INT(stratum_shares, &id, sshare); HASH_FIND_INT(stratum_shares, &id, sshare);
if (sshare) { if (sshare) {
@ -5673,7 +5682,7 @@ retry_stratum:
bool init = pool_tset(pool, &pool->stratum_init); bool init = pool_tset(pool, &pool->stratum_init);
if (!init) { if (!init) {
bool ret = initiate_stratum(pool) && auth_stratum(pool); bool ret = initiate_stratum(pool) && auth_stratum(pool) && subscribe_extranonce(pool);
if (ret) if (ret)
init_stratum_threads(pool); init_stratum_threads(pool);

18
util.c

@ -1876,6 +1876,22 @@ bool parse_method(struct pool *pool, char *s)
return ret; return ret;
} }
bool subscribe_extranonce(struct pool *pool)
{
char s[RBUFSIZE];
bool ret = false;
sprintf(s, "{\"id\": %d, \"method\": \"mining.extranonce.subscribe\", \"params\": []}",
swork_id++);
if (!stratum_send(pool, s, strlen(s)))
return ret;
ret = true;
applog(LOG_INFO, "Stratum extranonce subscribe for %s", get_pool_name(pool));
return ret;
}
bool auth_stratum(struct pool *pool) bool auth_stratum(struct pool *pool)
{ {
json_t *val = NULL, *res_val, *err_val; json_t *val = NULL, *res_val, *err_val;
@ -2506,6 +2522,8 @@ bool restart_stratum(struct pool *pool)
return false; return false;
if (!auth_stratum(pool)) if (!auth_stratum(pool))
return false; return false;
if (!subscribe_extranonce(pool))
return false;
return true; return true;
} }

Loading…
Cancel
Save