Browse Source

pool: abstract get_pool_name()

The introduction of get_pool_name() warrants a separate function
so opt_incognito does not litter everywhere.
build-mingw
Noel Maersk 11 years ago
parent
commit
8e4fb3c554
  1. 1
      Makefile.am
  2. 1
      miner.h
  3. 41
      pool.c
  4. 8
      pool.h
  5. 9
      sgminer.c

1
Makefile.am

@ -41,6 +41,7 @@ sgminer_SOURCES += driver-opencl.c driver-opencl.h @@ -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

1
miner.h

@ -986,6 +986,7 @@ extern bool opt_restart; @@ -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;

41
pool.c

@ -0,0 +1,41 @@ @@ -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 <stdlib.h>
#include <stdint.h>
#include <string.h>
char* get_pool_name(struct pool *pool) {
if (opt_incognito) return "<incognito>";
if (strcmp(pool->poolname, "") == 0) return pool->sockaddr_url;
return pool->poolname;
}

8
pool.h

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
#ifndef POOL_H
#define POOL_H
#include "miner.h"
extern char* get_pool_name(struct pool *pool);
#endif /* POOL_H */

9
sgminer.c

@ -55,6 +55,7 @@ char *curly = ":D"; @@ -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 <errno.h>
@ -816,7 +817,7 @@ static char *set_pool_state(char *arg) @@ -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, @@ -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);

Loading…
Cancel
Save