Browse Source

Reverting "poolname" to "name".

build-mingw
troky 10 years ago committed by Noel Maersk
parent
commit
49aef7100f
  1. 2
      miner.h
  2. 11
      pool.c
  3. 52
      sgminer.c
  4. 28
      util.c

2
miner.h

@ -1179,7 +1179,7 @@ struct stratum_work { @@ -1179,7 +1179,7 @@ struct stratum_work {
struct pool {
int pool_no;
char *poolname;
char *name;
int prio;
int accepted, rejected;
int seq_rejects;

11
pool.c

@ -36,15 +36,18 @@ @@ -36,15 +36,18 @@
#include <string.h>
char* get_pool_name(struct pool *pool) {
if (opt_incognito) return "<pool>";
if (opt_incognito)
return "<pool>";
if (strcmp(pool->poolname, "") == 0) return pool->sockaddr_url;
if (strcmp(pool->name, "") == 0)
return pool->sockaddr_url;
return pool->poolname;
return pool->name;
}
char* get_pool_user(struct pool *pool) {
if (opt_incognito) return "<user>";
if (opt_incognito)
return "<user>";
return pool->rpc_user;
}

52
sgminer.c

@ -533,7 +533,7 @@ struct pool *add_pool(void) @@ -533,7 +533,7 @@ struct pool *add_pool(void)
/* Default pool name */
char buf[32];
sprintf(buf, "", pool->pool_no);
pool->poolname = strdup(buf);
pool->name = strdup(buf);
pools = (struct pool **)realloc(pools, sizeof(struct pool *) * (total_pools + 2));
pools[total_pools++] = pool;
@ -761,7 +761,7 @@ static char *set_poolname(char *arg) @@ -761,7 +761,7 @@ static char *set_poolname(char *arg)
pool = pools[json_array_index];
applog(LOG_DEBUG, "Setting pool %i name to %s", pool->pool_no, arg);
opt_set_charp(arg, &pool->poolname);
opt_set_charp(arg, &pool->name);
return NULL;
}
@ -1268,7 +1268,7 @@ static struct opt_table opt_config_table[] = { @@ -1268,7 +1268,7 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--per-device-stats",
opt_set_bool, &want_per_device_stats,
"Force verbose mode and output per-device statistics"),
OPT_WITH_ARG("--poolname",
OPT_WITH_ARG("--name",
set_poolname, NULL, NULL,
"Name of pool."),
OPT_WITHOUT_ARG("--protocol-dump|-P",
@ -1754,17 +1754,17 @@ static void update_gbt(struct pool *pool) @@ -1754,17 +1754,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->poolname);
applog(LOG_DEBUG, "Successfully retrieved and updated GBT from %s", pool->name);
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->poolname);
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher GBT from %s", pool->name);
}
json_decref(val);
free_work(work);
} else {
applog(LOG_DEBUG, "FAILED to update GBT from %s", pool->poolname);
applog(LOG_DEBUG, "FAILED to update GBT from %s", pool->name);
}
curl_easy_cleanup(curl);
}
@ -2518,7 +2518,7 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work, @@ -2518,7 +2518,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->poolname);
snprintf(where, sizeof(where), "%s", work->pool->name);
else
strcpy(where, "");
@ -2952,7 +2952,7 @@ static inline struct pool *select_pool(bool lagging) @@ -2952,7 +2952,7 @@ static inline struct pool *select_pool(bool lagging)
if (!pool)
pool = cp;
out:
applog(LOG_DEBUG, "Selecting %s for work", pool->poolname);
applog(LOG_DEBUG, "Selecting %s for work", pool->name);
return pool;
}
@ -3261,7 +3261,7 @@ retry: @@ -3261,7 +3261,7 @@ retry:
mutex_unlock(&pool->pool_lock);
if (recruited)
applog(LOG_DEBUG, "Recruited curl for %s", pool->poolname);
applog(LOG_DEBUG, "Recruited curl for %s", pool->name);
return ce;
}
@ -4012,7 +4012,7 @@ static bool test_work_current(struct work *work) @@ -4012,7 +4012,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->poolname);
work->gbt ? "GBT " : "", work->pool->name);
}
} else if (have_longpoll)
applog(LOG_NOTICE, "New block detected on network before pool notification");
@ -4027,12 +4027,12 @@ static bool test_work_current(struct work *work) @@ -4027,12 +4027,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->poolname);
applog(LOG_DEBUG, "Stale data from %s", pool->name);
ret = false;
} else {
/* Work is from new block and pool is up now
* current. */
applog(LOG_INFO, "%s now up to date", pool->poolname);
applog(LOG_INFO, "%s now up to date", pool->name);
memcpy(pool->prev_block, bedata, 32);
}
}
@ -4041,7 +4041,7 @@ static bool test_work_current(struct work *work) @@ -4041,7 +4041,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->poolname);
applog(LOG_DEBUG, "%s still on old block", pool->name);
#endif
if (work->longpoll) {
work->work_block = ++work_block;
@ -4049,7 +4049,7 @@ static bool test_work_current(struct work *work) @@ -4049,7 +4049,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->poolname);
applog(LOG_NOTICE, "%sLONGPOLL from %s requested work restart", work->gbt ? "GBT " : "", work->pool->name);
}
restart_threads();
}
@ -4091,7 +4091,7 @@ static bool hash_push(struct work *work) @@ -4091,7 +4091,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->poolname);
applog(LOG_DEBUG, "Pushing work from %s to hash queue", work->pool->name);
work->work_block = work_block;
test_work_current(work);
work->pool->works++;
@ -5368,7 +5368,7 @@ static void *stratum_rthread(void *userdata) @@ -5368,7 +5368,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->poolname, sel_ret);
applog(LOG_DEBUG, "Stratum select failed on %s with value %d", pool->name, sel_ret);
s = NULL;
} else
s = recv_line(pool);
@ -5591,9 +5591,9 @@ static bool pool_active(struct pool *pool, bool pinging) @@ -5591,9 +5591,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->poolname);
applog(LOG_DEBUG, "Retrieving block template from %s", pool->name);
else
applog(LOG_INFO, "Testing %s", pool->poolname);
applog(LOG_INFO, "Testing %s", pool->name);
/* This is the central point we activate stratum when we can */
retry_stratum:
@ -5693,7 +5693,7 @@ retry_stratum: @@ -5693,7 +5693,7 @@ retry_stratum:
rc = work_decode(pool, work, val);
if (rc) {
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from %s", pool->poolname);
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from %s", pool->name);
work->pool = pool;
work->rolltime = rolltime;
copy_time(&work->tv_getwork, &tv_getwork);
@ -5708,7 +5708,7 @@ retry_stratum: @@ -5708,7 +5708,7 @@ retry_stratum:
ret = true;
cgtime(&pool->tv_idle);
} else {
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher work from %s", pool->poolname);
applog(LOG_DEBUG, "Successfully retrieved but FAILED to decipher work from %s", pool->name);
free_work(work);
}
json_decref(val);
@ -5756,7 +5756,7 @@ retry_stratum: @@ -5756,7 +5756,7 @@ retry_stratum:
pool->has_stratum = true;
goto retry_stratum;
}
applog(LOG_DEBUG, "FAILED to retrieve work from %s", pool->poolname);
applog(LOG_DEBUG, "FAILED to retrieve work from %s", pool->name);
if (!pinging)
applog(LOG_WARNING, "%s slow/down or URL or credentials invalid", get_pool_name(pool));
}
@ -6040,7 +6040,7 @@ static void submit_work_async(struct work *work) @@ -6040,7 +6040,7 @@ static void submit_work_async(struct work *work)
}
if (work->stratum) {
applog(LOG_DEBUG, "Pushing %s work to stratum queue", pool->poolname);
applog(LOG_DEBUG, "Pushing %s work to stratum queue", pool->name);
if (unlikely(!tq_push(pool->stratum_q, work))) {
applog(LOG_DEBUG, "Discarding work from removed pool");
free_work(work);
@ -6113,7 +6113,7 @@ static void update_work_stats(struct thr_info *thr, struct work *work) @@ -6113,7 +6113,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->poolname);
applog(LOG_NOTICE, "Found block for %s!", work->pool->name);
}
mutex_lock(&stats_lock);
@ -6968,7 +6968,7 @@ static void reap_curl(struct pool *pool) @@ -6968,7 +6968,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->poolname);
applog(LOG_DEBUG, "Reaped %d curl%s from %s", reaped, reaped > 1 ? "s" : "", pool->name);
}
static void *watchpool_thread(void __maybe_unused *userdata)
@ -8270,7 +8270,7 @@ begin_bench: @@ -8270,7 +8270,7 @@ begin_bench:
work = make_work();
if (lagging && !pool_tset(cp, &cp->lagging)) {
applog(LOG_WARNING, "%s not providing work fast enough", cp->poolname);
applog(LOG_WARNING, "%s not providing work fast enough", cp->name);
cp->getfail_occasions++;
total_go++;
if (!pool_localgen(cp))
@ -8330,7 +8330,7 @@ retry: @@ -8330,7 +8330,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->poolname);
applog(LOG_DEBUG, "%s json_rpc_call failed on get work, retrying in 5s", pool->name);
/* 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

@ -1306,7 +1306,7 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len) @@ -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->poolname);
applog(LOG_DEBUG, "Write select failed on %s sock", pool->name);
suspend_stratum(pool);
break;
case SEND_SENDFAIL:
@ -1659,7 +1659,7 @@ static bool parse_diff(struct pool *pool, json_t *val) @@ -1659,7 +1659,7 @@ static bool parse_diff(struct pool *pool, json_t *val)
else
applog(LOG_NOTICE, "%s difficulty changed to %.1f", get_pool_name(pool), diff);
} else
applog(LOG_DEBUG, "%s difficulty set to %f", pool->poolname, diff);
applog(LOG_DEBUG, "%s difficulty set to %f", pool->name, diff);
return true;
}
@ -1692,7 +1692,7 @@ static bool parse_reconnect(struct pool *pool, json_t *val) @@ -1692,7 +1692,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->poolname, address);
applog(LOG_NOTICE, "Reconnect requested from %s to %s", pool->name, address);
clear_pool_work(pool);
@ -1737,7 +1737,7 @@ static bool show_message(struct pool *pool, json_t *val) @@ -1737,7 +1737,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->poolname, msg);
applog(LOG_NOTICE, "%s message: %s", pool->name, msg);
return true;
}
@ -1859,14 +1859,14 @@ bool auth_stratum(struct pool *pool) @@ -1859,14 +1859,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->poolname, ss);
applog(LOG_INFO, "%s JSON stratum auth failed: %s", pool->name, ss);
free(ss);
goto out;
}
ret = true;
applog(LOG_INFO, "Stratum authorisation success for %s", pool->poolname);
applog(LOG_INFO, "Stratum authorisation success for %s", pool->name);
pool->probed = true;
successful_connect = true;
@ -2126,7 +2126,7 @@ static bool setup_stratum_socket(struct pool *pool) @@ -2126,7 +2126,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->poolname);
applog(LOG_INFO, "Closing %s socket", pool->name);
CLOSESOCKET(pool->sock);
}
pool->sock = 0;
@ -2295,7 +2295,7 @@ out: @@ -2295,7 +2295,7 @@ out:
void suspend_stratum(struct pool *pool)
{
applog(LOG_INFO, "Closing socket for stratum %s", pool->poolname);
applog(LOG_INFO, "Closing socket for stratum %s", pool->name);
mutex_lock(&pool->stratum_lock);
__suspend_stratum(pool);
@ -2313,7 +2313,7 @@ bool initiate_stratum(struct pool *pool) @@ -2313,7 +2313,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->poolname);
applog(LOG_INFO, "setup_stratum_socket() on %s failed", pool->name);
sockd = false;
goto out;
}
@ -2403,7 +2403,7 @@ resend: @@ -2403,7 +2403,7 @@ resend:
cg_wunlock(&pool->data_lock);
if (sessionid)
applog(LOG_DEBUG, "%s stratum session id: %s", pool->poolname, pool->sessionid);
applog(LOG_DEBUG, "%s stratum session id: %s", pool->name, pool->sessionid);
ret = true;
out:
@ -2414,7 +2414,7 @@ out: @@ -2414,7 +2414,7 @@ out:
pool->swork.diff = 1;
if (opt_protocol) {
applog(LOG_DEBUG, "%s confirmed mining.subscribe with extranonce1 %s extran2size %d",
pool->poolname, pool->nonce1, pool->n2size);
pool->name, pool->nonce1, pool->n2size);
}
} else {
if (recvd && !noresume) {
@ -2432,9 +2432,9 @@ out: @@ -2432,9 +2432,9 @@ out:
json_decref(val);
goto resend;
}
applog(LOG_DEBUG, "Initiating stratum failed on %s", pool->poolname);
applog(LOG_DEBUG, "Initiating stratum failed on %s", pool->name);
if (sockd) {
applog(LOG_DEBUG, "Suspending stratum on %s", pool->poolname);
applog(LOG_DEBUG, "Suspending stratum on %s", pool->name);
suspend_stratum(pool);
}
}
@ -2445,7 +2445,7 @@ out: @@ -2445,7 +2445,7 @@ out:
bool restart_stratum(struct pool *pool)
{
applog(LOG_DEBUG, "Restarting stratum on pool %s", pool->poolname);
applog(LOG_DEBUG, "Restarting stratum on pool %s", pool->name);
if (pool->stratum_active)
suspend_stratum(pool);

Loading…
Cancel
Save