mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-01 18:55:36 +00:00
Merge pull request #200 from Elbandi/poolnamefix
Use get_pool_name everywhere
This commit is contained in:
commit
897ca9fd4c
2
api.c
2
api.c
@ -1818,7 +1818,7 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
||||
lp = (char *)NO;
|
||||
|
||||
root = api_add_int(root, "POOL", &i, false);
|
||||
root = api_add_string(root, "Name", pool->name, false);
|
||||
root = api_add_string(root, "Name", get_pool_name(pool), false);
|
||||
root = api_add_escape(root, "URL", pool->rpc_url, false);
|
||||
root = api_add_string(root, "Algorithm", pool->algorithm.name, false);
|
||||
root = api_add_string(root, "Description", pool->description, false);
|
||||
|
44
sgminer.c
44
sgminer.c
@ -1825,17 +1825,17 @@ static void update_gbt(struct pool *pool)
|
||||
total_getworks++;
|
||||
pool->getwork_requested++;
|
||||
if (rc) {
|
||||
applog(LOG_DEBUG, "Successfully retrieved and updated GBT from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Successfully retrieved and updated GBT from %s", get_pool_name(pool));
|
||||
cgtime(&pool->tv_idle);
|
||||
if (pool == current_pool())
|
||||
opt_work_update = true;
|
||||
} else {
|
||||
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher GBT from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher GBT from %s", get_pool_name(pool));
|
||||
}
|
||||
json_decref(val);
|
||||
free_work(work);
|
||||
} else {
|
||||
applog(LOG_DEBUG, "FAILED to update GBT from %s", pool->name);
|
||||
applog(LOG_DEBUG, "FAILED to update GBT from %s", get_pool_name(pool));
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
@ -2589,7 +2589,7 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
|
||||
|
||||
strcpy(reason, "");
|
||||
if (total_pools > 1)
|
||||
snprintf(where, sizeof(where), "%s", work->pool->name);
|
||||
snprintf(where, sizeof(where), "%s", get_pool_name(pool));
|
||||
else
|
||||
strcpy(where, "");
|
||||
|
||||
@ -3023,7 +3023,7 @@ static inline struct pool *select_pool(bool lagging)
|
||||
if (!pool)
|
||||
pool = cp;
|
||||
out:
|
||||
applog(LOG_DEBUG, "Selecting %s for work", pool->name);
|
||||
applog(LOG_DEBUG, "Selecting %s for work", get_pool_name(pool));
|
||||
return pool;
|
||||
}
|
||||
|
||||
@ -3332,7 +3332,7 @@ retry:
|
||||
mutex_unlock(&pool->pool_lock);
|
||||
|
||||
if (recruited)
|
||||
applog(LOG_DEBUG, "Recruited curl for %s", pool->name);
|
||||
applog(LOG_DEBUG, "Recruited curl for %s", get_pool_name(pool));
|
||||
return ce;
|
||||
}
|
||||
|
||||
@ -4082,7 +4082,7 @@ static bool test_work_current(struct work *work)
|
||||
applog(LOG_NOTICE, "Stratum from %s detected new block", get_pool_name(pool));
|
||||
} else {
|
||||
applog(LOG_NOTICE, "%sLONGPOLL from %s detected new block",
|
||||
work->gbt ? "GBT " : "", work->pool->name);
|
||||
work->gbt ? "GBT " : "", get_pool_name(pool));
|
||||
}
|
||||
} else if (have_longpoll)
|
||||
applog(LOG_NOTICE, "New block detected on network before pool notification");
|
||||
@ -4097,12 +4097,12 @@ static bool test_work_current(struct work *work)
|
||||
* block. */
|
||||
if (memcmp(bedata, current_block, 32)) {
|
||||
/* Doesn't match current block. It's stale */
|
||||
applog(LOG_DEBUG, "Stale data from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Stale data from %s", get_pool_name(pool));
|
||||
ret = false;
|
||||
} else {
|
||||
/* Work is from new block and pool is up now
|
||||
* current. */
|
||||
applog(LOG_INFO, "%s now up to date", pool->name);
|
||||
applog(LOG_INFO, "%s now up to date", get_pool_name(pool));
|
||||
memcpy(pool->prev_block, bedata, 32);
|
||||
}
|
||||
}
|
||||
@ -4111,7 +4111,7 @@ static bool test_work_current(struct work *work)
|
||||
* accepting shares from it. To maintain fair work distribution
|
||||
* we work on it anyway. */
|
||||
if (memcmp(bedata, current_block, 32))
|
||||
applog(LOG_DEBUG, "%s still on old block", pool->name);
|
||||
applog(LOG_DEBUG, "%s still on old block", get_pool_name(pool));
|
||||
#endif
|
||||
if (work->longpoll) {
|
||||
work->work_block = ++work_block;
|
||||
@ -4119,7 +4119,7 @@ static bool test_work_current(struct work *work)
|
||||
if (work->stratum) {
|
||||
applog(LOG_NOTICE, "Stratum from %s requested work restart", get_pool_name(pool));
|
||||
} else {
|
||||
applog(LOG_NOTICE, "%sLONGPOLL from %s requested work restart", work->gbt ? "GBT " : "", work->pool->name);
|
||||
applog(LOG_NOTICE, "%sLONGPOLL from %s requested work restart", work->gbt ? "GBT " : "", get_pool_name(pool));
|
||||
}
|
||||
restart_threads();
|
||||
}
|
||||
@ -4161,7 +4161,7 @@ static bool hash_push(struct work *work)
|
||||
|
||||
static void stage_work(struct work *work)
|
||||
{
|
||||
applog(LOG_DEBUG, "Pushing work from %s to hash queue", work->pool->name);
|
||||
applog(LOG_DEBUG, "Pushing work from %s to hash queue", get_pool_name(work->pool));
|
||||
work->work_block = work_block;
|
||||
test_work_current(work);
|
||||
work->pool->works++;
|
||||
@ -5436,7 +5436,7 @@ static void *stratum_rthread(void *userdata)
|
||||
* assume the connection has been dropped and treat this pool
|
||||
* as dead */
|
||||
if (!sock_full(pool) && (sel_ret = select(pool->sock + 1, &rd, NULL, NULL, &timeout)) < 1) {
|
||||
applog(LOG_DEBUG, "Stratum select failed on %s with value %d", pool->name, sel_ret);
|
||||
applog(LOG_DEBUG, "Stratum select failed on %s with value %d", get_pool_name(pool), sel_ret);
|
||||
s = NULL;
|
||||
} else
|
||||
s = recv_line(pool);
|
||||
@ -5659,9 +5659,9 @@ static bool pool_active(struct pool *pool, bool pinging)
|
||||
int rolltime = 0;
|
||||
|
||||
if (pool->has_gbt)
|
||||
applog(LOG_DEBUG, "Retrieving block template from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Retrieving block template from %s", get_pool_name(pool));
|
||||
else
|
||||
applog(LOG_INFO, "Testing %s", pool->name);
|
||||
applog(LOG_INFO, "Testing %s", get_pool_name(pool));
|
||||
|
||||
/* This is the central point we activate stratum when we can */
|
||||
retry_stratum:
|
||||
@ -5761,7 +5761,7 @@ retry_stratum:
|
||||
|
||||
rc = work_decode(pool, work, val);
|
||||
if (rc) {
|
||||
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from %s", get_pool_name(pool));
|
||||
work->pool = pool;
|
||||
work->rolltime = rolltime;
|
||||
copy_time(&work->tv_getwork, &tv_getwork);
|
||||
@ -5776,7 +5776,7 @@ retry_stratum:
|
||||
ret = true;
|
||||
cgtime(&pool->tv_idle);
|
||||
} else {
|
||||
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher work from %s", pool->name);
|
||||
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher work from %s", get_pool_name(pool));
|
||||
free_work(work);
|
||||
}
|
||||
json_decref(val);
|
||||
@ -5824,7 +5824,7 @@ retry_stratum:
|
||||
pool->has_stratum = true;
|
||||
goto retry_stratum;
|
||||
}
|
||||
applog(LOG_DEBUG, "FAILED to retrieve work from %s", pool->name);
|
||||
applog(LOG_DEBUG, "FAILED to retrieve work from %s", get_pool_name(pool));
|
||||
if (!pinging)
|
||||
applog(LOG_WARNING, "%s slow/down or URL or credentials invalid", get_pool_name(pool));
|
||||
}
|
||||
@ -6158,7 +6158,7 @@ static void submit_work_async(struct work *work)
|
||||
}
|
||||
|
||||
if (work->stratum) {
|
||||
applog(LOG_DEBUG, "Pushing %s work to stratum queue", pool->name);
|
||||
applog(LOG_DEBUG, "Pushing %s work to stratum queue", get_pool_name(pool));
|
||||
if (unlikely(!tq_push(pool->stratum_q, work))) {
|
||||
applog(LOG_DEBUG, "Discarding work from removed pool");
|
||||
free_work(work);
|
||||
@ -6231,7 +6231,7 @@ static void update_work_stats(struct thr_info *thr, struct work *work)
|
||||
work->pool->solved++;
|
||||
found_blocks++;
|
||||
work->mandatory = true;
|
||||
applog(LOG_NOTICE, "Found block for %s!", work->pool->name);
|
||||
applog(LOG_NOTICE, "Found block for %s!", get_pool_name(work->pool));
|
||||
}
|
||||
|
||||
mutex_lock(&stats_lock);
|
||||
@ -7088,7 +7088,7 @@ static void reap_curl(struct pool *pool)
|
||||
mutex_unlock(&pool->pool_lock);
|
||||
|
||||
if (reaped)
|
||||
applog(LOG_DEBUG, "Reaped %d curl%s from %s", reaped, reaped > 1 ? "s" : "", pool->name);
|
||||
applog(LOG_DEBUG, "Reaped %d curl%s from %s", reaped, reaped > 1 ? "s" : "", get_pool_name(pool));
|
||||
}
|
||||
|
||||
static void *watchpool_thread(void __maybe_unused *userdata)
|
||||
@ -8469,7 +8469,7 @@ retry:
|
||||
ce = pop_curl_entry(pool);
|
||||
/* obtain new work from bitcoin via JSON-RPC */
|
||||
if (!get_upstream_work(work, ce->curl)) {
|
||||
applog(LOG_DEBUG, "%s json_rpc_call failed on get work, retrying in 5s", pool->name);
|
||||
applog(LOG_DEBUG, "%s json_rpc_call failed on get work, retrying in 5s", get_pool_name(pool));
|
||||
/* Make sure the pool just hasn't stopped serving
|
||||
* requests but is up as we'll keep hammering it */
|
||||
if (++pool->seq_getfails > mining_threads + opt_queue)
|
||||
|
28
util.c
28
util.c
@ -1306,7 +1306,7 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
|
||||
case SEND_OK:
|
||||
break;
|
||||
case SEND_SELECTFAIL:
|
||||
applog(LOG_DEBUG, "Write select failed on %s sock", pool->name);
|
||||
applog(LOG_DEBUG, "Write select failed on %s sock", get_pool_name(pool));
|
||||
suspend_stratum(pool);
|
||||
break;
|
||||
case SEND_SENDFAIL:
|
||||
@ -1659,7 +1659,7 @@ static bool parse_diff(struct pool *pool, json_t *val)
|
||||
else
|
||||
applog(pool == current_pool() ? LOG_NOTICE : LOG_DEBUG, "%s difficulty changed to %.1f", get_pool_name(pool), diff);
|
||||
} else
|
||||
applog(LOG_DEBUG, "%s difficulty set to %f", pool->name, diff);
|
||||
applog(LOG_DEBUG, "%s difficulty set to %f", get_pool_name(pool), diff);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1697,7 +1697,7 @@ static bool parse_reconnect(struct pool *pool, json_t *val)
|
||||
if (!extract_sockaddr(address, &sockaddr_url, &stratum_port))
|
||||
return false;
|
||||
|
||||
applog(LOG_NOTICE, "Reconnect requested from %s to %s", pool->name, address);
|
||||
applog(LOG_NOTICE, "Reconnect requested from %s to %s", get_pool_name(pool), address);
|
||||
|
||||
clear_pool_work(pool);
|
||||
|
||||
@ -1742,7 +1742,7 @@ static bool show_message(struct pool *pool, json_t *val)
|
||||
msg = (char *)json_string_value(json_array_get(val, 0));
|
||||
if (!msg)
|
||||
return false;
|
||||
applog(LOG_NOTICE, "%s message: %s", pool->name, msg);
|
||||
applog(LOG_NOTICE, "%s message: %s", get_pool_name(pool), msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1864,14 +1864,14 @@ bool auth_stratum(struct pool *pool)
|
||||
ss = json_dumps(err_val, JSON_INDENT(3));
|
||||
else
|
||||
ss = strdup("(unknown reason)");
|
||||
applog(LOG_INFO, "%s JSON stratum auth failed: %s", pool->name, ss);
|
||||
applog(LOG_INFO, "%s JSON stratum auth failed: %s", get_pool_name(pool), ss);
|
||||
free(ss);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = true;
|
||||
applog(LOG_INFO, "Stratum authorisation success for %s", pool->name);
|
||||
applog(LOG_INFO, "Stratum authorisation success for %s", get_pool_name(pool));
|
||||
pool->probed = true;
|
||||
successful_connect = true;
|
||||
|
||||
@ -2131,7 +2131,7 @@ static bool setup_stratum_socket(struct pool *pool)
|
||||
pool->stratum_active = false;
|
||||
if (pool->sock) {
|
||||
/* FIXME: change to LOG_DEBUG if issue #88 resolved */
|
||||
applog(LOG_INFO, "Closing %s socket", pool->name);
|
||||
applog(LOG_INFO, "Closing %s socket", get_pool_name(pool));
|
||||
CLOSESOCKET(pool->sock);
|
||||
}
|
||||
pool->sock = 0;
|
||||
@ -2300,7 +2300,7 @@ out:
|
||||
|
||||
void suspend_stratum(struct pool *pool)
|
||||
{
|
||||
applog(LOG_INFO, "Closing socket for stratum %s", pool->name);
|
||||
applog(LOG_INFO, "Closing socket for stratum %s", get_pool_name(pool));
|
||||
|
||||
mutex_lock(&pool->stratum_lock);
|
||||
__suspend_stratum(pool);
|
||||
@ -2318,7 +2318,7 @@ bool initiate_stratum(struct pool *pool)
|
||||
resend:
|
||||
if (!setup_stratum_socket(pool)) {
|
||||
/* FIXME: change to LOG_DEBUG when issue #88 resolved */
|
||||
applog(LOG_INFO, "setup_stratum_socket() on %s failed", pool->name);
|
||||
applog(LOG_INFO, "setup_stratum_socket() on %s failed", get_pool_name(pool));
|
||||
sockd = false;
|
||||
goto out;
|
||||
}
|
||||
@ -2408,7 +2408,7 @@ resend:
|
||||
cg_wunlock(&pool->data_lock);
|
||||
|
||||
if (sessionid)
|
||||
applog(LOG_DEBUG, "%s stratum session id: %s", pool->name, pool->sessionid);
|
||||
applog(LOG_DEBUG, "%s stratum session id: %s", get_pool_name(pool), pool->sessionid);
|
||||
|
||||
ret = true;
|
||||
out:
|
||||
@ -2419,7 +2419,7 @@ out:
|
||||
pool->swork.diff = 1;
|
||||
if (opt_protocol) {
|
||||
applog(LOG_DEBUG, "%s confirmed mining.subscribe with extranonce1 %s extran2size %d",
|
||||
pool->name, pool->nonce1, pool->n2size);
|
||||
get_pool_name(pool), pool->nonce1, pool->n2size);
|
||||
}
|
||||
} else {
|
||||
if (recvd && !noresume) {
|
||||
@ -2437,9 +2437,9 @@ out:
|
||||
json_decref(val);
|
||||
goto resend;
|
||||
}
|
||||
applog(LOG_DEBUG, "Initiating stratum failed on %s", pool->name);
|
||||
applog(LOG_DEBUG, "Initiating stratum failed on %s", get_pool_name(pool));
|
||||
if (sockd) {
|
||||
applog(LOG_DEBUG, "Suspending stratum on %s", pool->name);
|
||||
applog(LOG_DEBUG, "Suspending stratum on %s", get_pool_name(pool));
|
||||
suspend_stratum(pool);
|
||||
}
|
||||
}
|
||||
@ -2450,7 +2450,7 @@ out:
|
||||
|
||||
bool restart_stratum(struct pool *pool)
|
||||
{
|
||||
applog(LOG_DEBUG, "Restarting stratum on pool %s", pool->name);
|
||||
applog(LOG_DEBUG, "Restarting stratum on pool %s", get_pool_name(pool));
|
||||
|
||||
if (pool->stratum_active)
|
||||
suspend_stratum(pool);
|
||||
|
Loading…
Reference in New Issue
Block a user