upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r--src/main_gui.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 2484592..852ad4d 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -1,6 +1,7 @@
1// Bitflash entry point -- starts node threads then runs GUI (or headless). 1// Bitflash entry point -- starts node threads then runs GUI (or headless).
2 2
3#include "headers_core.h" 3#include "headers_core.h"
4#include <thread> // hardware_concurrency, to sanity-check /genproclimit
4#ifndef _WIN32 5#ifndef _WIN32
5#include <csignal> 6#include <csignal>
6#endif 7#endif
@@ -52,6 +53,7 @@ static void PrintUsage()
52 printf(" /operator\n"); 53 printf(" /operator\n");
53 printf(" /participant=POOL_BTF_ADDRESS\n"); 54 printf(" /participant=POOL_BTF_ADDRESS\n");
54 printf(" /solomine\n"); 55 printf(" /solomine\n");
56 printf(" /genproclimit=N (mining threads; 0 or absent = every core but one)\n");
55 printf("\n"); 57 printf("\n");
56 printf("Pool operator announcement:\n"); 58 printf("Pool operator announcement:\n");
57 printf(" /poolname=NAME\n"); 59 printf(" /poolname=NAME\n");
@@ -99,6 +101,26 @@ static void ParseStartupArguments(int argc, char* argv[])
99 if (arg(argc,argv,"/solomine") || arg(argc,argv,"-solomine")) 101 if (arg(argc,argv,"/solomine") || arg(argc,argv,"-solomine"))
100 fSoloMineTest = true; 102 fSoloMineTest = true;
101 103
104 // /genproclimit=N -- threads to hash with. 0 or absent means automatic,
105 // which is every core but one. Named after Bitcoin's own option so it reads
106 // familiarly to anyone who has run one of these before.
107 string strProcLimit = argval2(argc, argv, "/genproclimit", "-genproclimit");
108 if (!strProcLimit.empty())
109 {
110 int n = atoi(strProcLimit.c_str());
111 unsigned int nCores = std::thread::hardware_concurrency();
112 if (n < 0)
113 fprintf(stderr, "Ignoring /genproclimit=%s: not a thread count\n",
114 strProcLimit.c_str());
115 else if (nCores > 0 && n > (int)nCores * 4)
116 // Well past diminishing returns, and every thread still costs a
117 // scratchpad. Refuse rather than quietly thrash the machine.
118 fprintf(stderr, "Ignoring /genproclimit=%d: this machine has %u core(s)\n",
119 n, nCores);
120 else
121 nMinerThreads = n; // 0 stays automatic
122 }
123
102 if (arg(argc,argv,"/operator") || arg(argc,argv,"-operator")) 124 if (arg(argc,argv,"/operator") || arg(argc,argv,"-operator"))
103 nMineMode = MINE_OPERATOR; 125 nMineMode = MINE_OPERATOR;
104 126
@@ -289,8 +311,7 @@ int main(int argc, char* argv[])
289 printf("Error: _beginthread(ThreadRPCServer) failed\n"); 311 printf("Error: _beginthread(ThreadRPCServer) failed\n");
290 } 312 }
291 if (fGenerateBitcoins) 313 if (fGenerateBitcoins)
292 if (_beginthread(ThreadBitcoinMiner, 0, NULL) == (uintptr_t)-1) 314 StartMinerThreads();
293 printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");
294 315
295#ifdef BITFLASH_NO_GUI 316#ifdef BITFLASH_NO_GUI
296 // Nothing else this binary can do; /nogui is accepted and redundant. 317 // Nothing else this binary can do; /nogui is accepted and redundant.