Browse Source

core: introduce `--incognito` + minimal revision of `--compact`.

`--incognito` is for sharing output without disclosing login
information.

NCurses interface code, as stated before, is pretty lousy.
build-mingw
Noel Maersk 11 years ago
parent
commit
f737992f41
  1. 67
      sgminer.c

67
sgminer.c

@ -86,7 +86,11 @@ bool use_syslog;
bool opt_quiet; bool opt_quiet;
bool opt_realquiet; bool opt_realquiet;
bool opt_loginput; bool opt_loginput;
#ifdef HAVE_CURSES
bool opt_compact; bool opt_compact;
bool opt_incognito;
#endif
const int opt_cutofftemp = 95; const int opt_cutofftemp = 95;
int opt_log_interval = 5; int opt_log_interval = 5;
int opt_queue = 1; int opt_queue = 1;
@ -1169,6 +1173,11 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--lookup-gap", OPT_WITH_ARG("--lookup-gap",
set_lookup_gap, NULL, NULL, set_lookup_gap, NULL, NULL,
"Set GPU lookup gap for scrypt mining, comma separated"), "Set GPU lookup gap for scrypt mining, comma separated"),
#ifdef HAVE_CURSES
OPT_WITHOUT_ARG("--incognito",
opt_set_bool, &opt_incognito,
"Do not display pool/user names in status window"),
#endif
OPT_WITH_ARG("--intensity|-I", OPT_WITH_ARG("--intensity|-I",
set_intensity, NULL, NULL, set_intensity, NULL, NULL,
"Intensity of GPU scanning (d or " MIN_INTENSITY_STR "Intensity of GPU scanning (d or " MIN_INTENSITY_STR
@ -1996,6 +2005,7 @@ static int devcursor, logstart, logcursor;
/* statusy is where the status window goes up to in cases where it won't fit at startup */ /* statusy is where the status window goes up to in cases where it won't fit at startup */
static int statusy; static int statusy;
#endif #endif
extern struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */ extern struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
@ -2145,31 +2155,42 @@ static bool shared_strategy(void)
static void curses_print_status(void) static void curses_print_status(void)
{ {
struct pool *pool = current_pool(); struct pool *pool = current_pool();
unsigned short int line = 0;
wattron(statuswin, A_BOLD); wattron(statuswin, A_BOLD);
cg_mvwprintw(statuswin, 0, 0, PACKAGE " " VERSION " - Started: %s", datestamp); cg_mvwprintw(statuswin, line, 0, PACKAGE " " VERSION " - Started: %s", datestamp);
wattroff(statuswin, A_BOLD); wattroff(statuswin, A_BOLD);
mvwhline(statuswin, 1, 0, '-', 80);
cg_mvwprintw(statuswin, 2, 0, "%s", statusline); mvwhline(statuswin, ++line, 0, '-', 80);
cg_mvwprintw(statuswin, ++line, 0, "%s", statusline);
wclrtoeol(statuswin); wclrtoeol(statuswin);
cg_mvwprintw(statuswin, 3, 0, "ST: %d SS: %d NB: %d LW: %d GF: %d RF: %d",
cg_mvwprintw(statuswin, ++line, 0, "ST: %d SS: %d NB: %d LW: %d GF: %d RF: %d",
total_staged(), total_stale, new_blocks, total_staged(), total_stale, new_blocks,
local_work, total_go, total_ro); local_work, total_go, total_ro);
wclrtoeol(statuswin); wclrtoeol(statuswin);
if (!opt_incognito) {
if (shared_strategy() && total_pools > 1) { if (shared_strategy() && total_pools > 1) {
cg_mvwprintw(statuswin, 4, 0, "Connected to multiple pools %s block change notify", cg_mvwprintw(statuswin, ++line, 0, "Connected to multiple pools %s block change notify",
have_longpoll ? "with": "without"); have_longpoll ? "with": "without");
} else { } else {
cg_mvwprintw(statuswin, 4, 0, "Connected to %s (%s) diff %s as user %s", cg_mvwprintw(statuswin, ++line, 0, "Connected to %s (%s) diff %s as user %s",
pool->poolname, pool->poolname,
pool->has_stratum ? "stratum" : (pool->has_gbt ? "GBT" : "longpoll"), pool->has_stratum ? "stratum" : (pool->has_gbt ? "GBT" : "longpoll"),
pool->diff, pool->rpc_user); pool->diff, pool->rpc_user);
} }
wclrtoeol(statuswin); wclrtoeol(statuswin);
cg_mvwprintw(statuswin, 5, 0, "Block: %s... Diff:%s Started: %s Best share: %s ", }
cg_mvwprintw(statuswin, ++line, 0, "Block: %s... Diff:%s Started: %s Best share: %s ",
prev_block, block_diff, blocktime, best_share); prev_block, block_diff, blocktime, best_share);
mvwhline(statuswin, 6, 0, '-', 80);
mvwhline(statuswin, ++line, 0, '-', 80);
mvwhline(statuswin, statusy - 1, 0, '-', 80); mvwhline(statuswin, statusy - 1, 0, '-', 80);
cg_mvwprintw(statuswin, devcursor - 1, 0, "[P]ool management [G]PU management [S]ettings [D]isplay options [Q]uit"); cg_mvwprintw(statuswin, devcursor - 1, 0, "[P]ool management [G]PU management [S]ettings [D]isplay options [Q]uit");
} }
@ -2191,9 +2212,7 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
struct timeval now; struct timeval now;
double dev_runtime, wu; double dev_runtime, wu;
if (opt_compact) /* Do not print if window vertical size too small. */
return;
if (devcursor + count > LINES - 2) if (devcursor + count > LINES - 2)
return; return;
@ -2213,8 +2232,8 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
cgpu->utility = cgpu->accepted / dev_runtime * 60; cgpu->utility = cgpu->accepted / dev_runtime * 60;
wu = cgpu->diff1 / dev_runtime * 60; wu = cgpu->diff1 / dev_runtime * 60;
wmove(statuswin,devcursor + count, 0); wmove(statuswin, devcursor + count, 0);
cg_wprintw(statuswin, " %s %*d: ", cgpu->drv->name, dev_width, cgpu->device_id); cg_wprintw(statuswin, "%s %*d: ", cgpu->drv->name, dev_width, cgpu->device_id);
logline[0] = '\0'; logline[0] = '\0';
cgpu->drv->get_statline_before(logline, sizeof(logline), cgpu); cgpu->drv->get_statline_before(logline, sizeof(logline), cgpu);
cg_wprintw(statuswin, "%s", logline); cg_wprintw(statuswin, "%s", logline);
@ -2316,11 +2335,10 @@ static void switch_logsize(bool __maybe_unused newdevs)
#endif #endif
if (opt_compact) { if (opt_compact) {
logstart = devcursor + 1; logstart = devcursor + 1;
logcursor = logstart + 1;
} else { } else {
logstart = devcursor + most_devices + 1; logstart = devcursor + most_devices + 1;
logcursor = logstart + 1;
} }
logcursor = logstart + 1;
#ifdef WIN32 #ifdef WIN32
if (newdevs) if (newdevs)
enable_curses_windows(); enable_curses_windows();
@ -7033,12 +7051,13 @@ static void *watchdog_thread(void __maybe_unused *userdata)
change_logwinsize(); change_logwinsize();
curses_print_status(); curses_print_status();
if (!opt_compact) {
count = 0; count = 0;
for (i = 0; i < total_devices; i++) { for (i = 0; i < total_devices; i++) {
cgpu = get_devices(i); cgpu = get_devices(i);
if (cgpu) curses_print_devstatus(cgpu, count++);
if (cgpu) }
curses_print_devstatus(cgpu, count++);
} }
touchwin(statuswin); touchwin(statuswin);
@ -7822,10 +7841,6 @@ int main(int argc, char *argv[])
strcat(sgminer_path, "\\"); strcat(sgminer_path, "\\");
#endif #endif
devcursor = 8;
logstart = devcursor + 1;
logcursor = logstart + 1;
block = (struct block *)calloc(sizeof(struct block), 1); block = (struct block *)calloc(sizeof(struct block), 1);
if (unlikely(!block)) if (unlikely(!block))
quit (1, "main OOM"); quit (1, "main OOM");
@ -7874,8 +7889,16 @@ int main(int argc, char *argv[])
if (use_curses) if (use_curses)
enable_curses(); enable_curses();
/* Print device stats from this line. */
devcursor = opt_incognito ? 7 : 8;
#else
devcursor = 8;
#endif #endif
logstart = devcursor + 1;
logcursor = logstart + 1;
applog(LOG_WARNING, "Started %s", packagename); applog(LOG_WARNING, "Started %s", packagename);
if (cnfbuf) { if (cnfbuf) {
applog(LOG_NOTICE, "Loaded configuration file %s", cnfbuf); applog(LOG_NOTICE, "Loaded configuration file %s", cnfbuf);

Loading…
Cancel
Save