From 8e4fb3c554689647df28ba364d828113b97f4b86 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Fri, 28 Feb 2014 22:14:59 +0200 Subject: [PATCH] pool: abstract get_pool_name() The introduction of get_pool_name() warrants a separate function so opt_incognito does not litter everywhere. --- Makefile.am | 1 + miner.h | 1 + pool.c | 41 +++++++++++++++++++++++++++++++++++++++++ pool.h | 8 ++++++++ sgminer.c | 9 +++++++-- 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 pool.c create mode 100644 pool.h diff --git a/Makefile.am b/Makefile.am index 1b753f36..06720ec8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,6 +41,7 @@ sgminer_SOURCES += driver-opencl.c driver-opencl.h sgminer_SOURCES += ocl.c ocl.h sgminer_SOURCES += findnonce.c findnonce.h sgminer_SOURCES += adl.c adl.h adl_functions.h +sgminer_SOURCES += pool.c pool.h sgminer_SOURCES += scrypt.c scrypt.h sgminer_SOURCES += kernel/*.cl diff --git a/miner.h b/miner.h index b7e4ef1f..ba515e38 100644 --- a/miner.h +++ b/miner.h @@ -986,6 +986,7 @@ extern bool opt_restart; extern bool opt_worktime; extern int swork_id; extern int opt_tcp_keepalive; +extern bool opt_incognito; #if LOCK_TRACKING extern pthread_mutex_t lockstat_lock; diff --git a/pool.c b/pool.c new file mode 100644 index 00000000..bd9e987f --- /dev/null +++ b/pool.c @@ -0,0 +1,41 @@ +/*- + * Copyright 2014 sgminer developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file was originally written by Colin Percival as part of the Tarsnap + * online backup system. + */ + +#include "config.h" +#include "miner.h" + +#include +#include +#include + +char* get_pool_name(struct pool *pool) { + if (opt_incognito) return ""; + if (strcmp(pool->poolname, "") == 0) return pool->sockaddr_url; + return pool->poolname; +} diff --git a/pool.h b/pool.h new file mode 100644 index 00000000..ab3705e1 --- /dev/null +++ b/pool.h @@ -0,0 +1,8 @@ +#ifndef POOL_H +#define POOL_H + +#include "miner.h" + +extern char* get_pool_name(struct pool *pool); + +#endif /* POOL_H */ diff --git a/sgminer.c b/sgminer.c index d9b1afa8..7ad5fa15 100644 --- a/sgminer.c +++ b/sgminer.c @@ -55,6 +55,7 @@ char *curly = ":D"; #include "driver-opencl.h" #include "bench_block.h" #include "scrypt.h" +#include "pool.h" #if defined(unix) || defined(__APPLE__) #include @@ -816,7 +817,7 @@ static char *set_pool_state(char *arg) add_pool(); pool = pools[json_array_index]; - applog(LOG_INFO, "Setting pool %s state to %s", pool->poolname, arg); + applog(LOG_INFO, "Setting pool %s state to %s", get_pool_name(pool), arg); if (strcmp(arg, "disabled") == 0) { pool->state = POOL_DISABLED; } else if (strcmp(arg, "enabled") == 0) { @@ -2441,7 +2442,11 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work, if (!QUIET) { if (total_pools > 1) { applog(LOG_NOTICE, "Accepted %s %s %d at %s %s%s", - hashshow, cgpu->drv->name, cgpu->device_id, pool->poolname, resubmit ? "(resubmit)" : "", worktime); + hashshow, + cgpu->drv->name, + cgpu->device_id, + get_pool_name(pool), + resubmit ? "(resubmit)" : "", worktime); } else applog(LOG_NOTICE, "Accepted %s %s %d %s%s", hashshow, cgpu->drv->name, cgpu->device_id, resubmit ? "(resubmit)" : "", worktime);