diff options
-rw-r--r-- | .appveyor.yml | 2 | ||||
-rw-r--r-- | .github/ISSUE_TEMPLATE.md | 30 | ||||
-rw-r--r-- | .github/PULL_REQUEST_TEMPLATE.md | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | doc/compile.md | 5 | ||||
-rw-r--r-- | doc/tuning.md | 6 | ||||
-rw-r--r-- | doc/usage.md | 22 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/autoAdjust.hpp | 2 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/config.tpl | 10 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/jconf.cpp | 11 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/jconf.hpp | 1 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/minethd.cpp | 1 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp | 3 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cuda_core.cu | 28 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp | 37 | ||||
-rw-r--r-- | xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu | 28 | ||||
-rw-r--r-- | xmrstak/cli/cli-miner.cpp | 59 | ||||
-rw-r--r-- | xmrstak/misc/executor.cpp | 24 | ||||
-rw-r--r-- | xmrstak/net/jpsock.hpp | 4 |
19 files changed, 217 insertions, 63 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index efa65bf..b463d0d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -22,7 +22,7 @@ build_script: - mkdir build - cd build - set CMAKE_PREFIX_PATH=C:\xmr-stak-dep\hwloc;C:\xmr-stak-dep\libmicrohttpd;C:\xmr-stak-dep\openssl; - - cmake -G "Visual Studio 14 2015 Win64" -T v140,host=x64 .. -DWIN_UAC=OFF -DCUDA_ARCH=30 + - cmake -G "Visual Studio 14 2015 Win64" -T v140,host=x64 .. -DCUDA_ARCH=30 - cmake --build . --config Release --target install test_script: diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..8451f32 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,30 @@ +Please provide as much as possible information to reproduce the issue. + +# Basic information + - Type of the CPU. + - Type of the GPU (if you try to miner with the GPU). + +# Compile issues + - Which OS do you use? + ``` + add **all** commands you used and the **full** compile output here + ``` + ``` + run `cmake -LA .` in the build folder and add the output here + ``` + +# Issue with the execution + - Do you compiled the miner by our own? + ``` + run `./xmr-stak --version-long` and add the output here + ``` + +# AMD OpenCl issue + + ``` + run `clinfo` and add the output here + ``` + +# Stability issue + - Is the CPU or GPU overclocked? + - Is the Main memory of the CPU or GPU undervolted? diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..16e55c8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1 @@ +Please make sure your PR is against **dev** branch. Merging PRs directly into master branch would interfere with our workflow.
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a444085..9540d7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,12 +521,6 @@ set(LIBRARY_OUTPUT_PATH "bin") target_link_libraries(xmr-stak ${LIBS} xmr-stak-c xmr-stak-backend) -option(WIN_UAC "Add UAC manifest on Windows" ON) - -if(WIN_UAC AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set_property(TARGET xmr-stak PROPERTY LINK_FLAGS "/level='requireAdministrator' /uiAccess='false'") -endif() - ################################################################################ # Install ################################################################################ diff --git a/doc/compile.md b/doc/compile.md index 4fa940f..e97affa 100644 --- a/doc/compile.md +++ b/doc/compile.md @@ -52,11 +52,6 @@ After the configuration you need to compile the miner, follow the guide for your - native means the miner binary can be used only on the system where it is compiled but will archive the highest hash rate - use `cmake .. -DXMR-STAK_COMPILE=generic` to run the miner on all CPU's with sse2 -### only available for Windows -- `WIN_UAC` will enable or disable the "Run As Administrator" prompt on Windows. - - UAC confirmation is needed to use large pages on Windows 7. - - On Windows 10 it is only needed once to set up the account to use them. - ## CPU Build Options - `CPU_ENABLE` allow to disable/enable the CPU backend of the miner diff --git a/doc/tuning.md b/doc/tuning.md index bb9a7e4..53e682b 100644 --- a/doc/tuning.md +++ b/doc/tuning.md @@ -1,6 +1,7 @@ # Tuning Guide ## Content Overview +* [Windows](windows) * [NVIDIA Backend](#nvidia-backend) * [Choose Value for `threads` and `blocks`](#choose-value-for-threads-and-blocks) * [Add more GPUs](#add-more-gpus) @@ -12,6 +13,11 @@ * [CPU Backend](#cpu-backend) * [Choose Value for `low_power_mode`](#choose-value-for-low_power_mode) +## Windows +"Run As Administrator" prompt (UAC) confirmation is needed to use large pages on Windows 7. +On Windows 10 it is only needed once to set up the account to use them. +Disable the dialog with the command line option `--noUAC` + ## NVIDIA Backend By default the NVIDIA backend can be tuned in the config file `nvidia.txt` diff --git a/doc/usage.md b/doc/usage.md index b516333..60cf69b 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -30,27 +30,7 @@ The number of files depends on the available backends. ## Command Line Options The miner allow to overwrite some of the settings via command line options. - -``` -Usage: xmr-stak [OPTION]... - - -h, --help show this help - -v, --version show version number - -V, --version-long show long version number - -c, --config FILE common miner configuration file - --currency NAME currency to mine: monero or aeon - --noCPU disable the CPU miner backend - --cpu FILE CPU backend miner config file - --noAMD disable the AMD miner backend - --amd FILE AMD backend miner config file - --noNVIDIA disable the NVIDIA miner backend - --nvidia FILE NVIDIA backend miner config file - -The Following options temporary overwrites the config file settings: - -o, --url URL pool url and port, e.g. pool.usxmrpool.com:3333 - -u, --user USERNAME pool user name or wallet address - -p, --pass PASSWD pool password, in the most cases x or empty "" -``` +Run `xmr-stak --help` to show all available command line options. ## Docker image usage diff --git a/xmrstak/backend/nvidia/autoAdjust.hpp b/xmrstak/backend/nvidia/autoAdjust.hpp index c6a7dca..be7d1ce 100644 --- a/xmrstak/backend/nvidia/autoAdjust.hpp +++ b/xmrstak/backend/nvidia/autoAdjust.hpp @@ -95,7 +95,7 @@ private: conf += std::string(" { \"index\" : ") + std::to_string(ctx.device_id) + ",\n" + " \"threads\" : " + std::to_string(ctx.device_threads) + ", \"blocks\" : " + std::to_string(ctx.device_blocks) + ",\n" + " \"bfactor\" : " + std::to_string(ctx.device_bfactor) + ", \"bsleep\" : " + std::to_string(ctx.device_bsleep) + ",\n" + - " \"affine_to_cpu\" : false,\n" + + " \"affine_to_cpu\" : false, \"sync_mode\" : 3,\n" + " },\n"; } } diff --git a/xmrstak/backend/nvidia/config.tpl b/xmrstak/backend/nvidia/config.tpl index 99dc023..5479172 100644 --- a/xmrstak/backend/nvidia/config.tpl +++ b/xmrstak/backend/nvidia/config.tpl @@ -9,6 +9,12 @@ R"===( * bsleep - Insert a delay of X microseconds between kernel launches. * Increase if you want to reduce GPU lag. Recommended setting on GUI systems - 100 * affine_to_cpu - This will affine the thread to a CPU. This can make a GPU miner play along nicer with a CPU miner. + * sync_mode - method used to synchronize the device + * documentation: http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g69e73c7dda3fc05306ae7c811a690fac + * 0 = cudaDeviceScheduleAuto + * 1 = cudaDeviceScheduleSpin - create a high load on one cpu thread per gpu + * 2 = cudaDeviceScheduleYield + * 3 = cudaDeviceScheduleBlockingSync (default) * * On the first run the miner will look at your system and suggest a basic configuration that will work, * you can try to tweak it from there to get the best performance. @@ -16,7 +22,9 @@ R"===( * A filled out configuration should look like this: * "gpu_threads_conf" : * [ - * { "index" : 0, "threads" : 17, "blocks" : 60, "bfactor" : 0, "bsleep" : 0, "affine_to_cpu" : false}, + * { "index" : 0, "threads" : 17, "blocks" : 60, "bfactor" : 0, "bsleep" : 0, + * "affine_to_cpu" : false, "sync_mode" : 3, + * }, * ], */ diff --git a/xmrstak/backend/nvidia/jconf.cpp b/xmrstak/backend/nvidia/jconf.cpp index 4208145..46c5726 100644 --- a/xmrstak/backend/nvidia/jconf.cpp +++ b/xmrstak/backend/nvidia/jconf.cpp @@ -123,16 +123,17 @@ bool jconf::GetGPUThreadConfig(size_t id, thd_cfg &cfg) if(!oThdConf.IsObject()) return false; - const Value *gid, *blocks, *threads, *bfactor, *bsleep, *aff; + const Value *gid, *blocks, *threads, *bfactor, *bsleep, *aff, *syncMode; gid = GetObjectMember(oThdConf, "index"); blocks = GetObjectMember(oThdConf, "blocks"); threads = GetObjectMember(oThdConf, "threads"); bfactor = GetObjectMember(oThdConf, "bfactor"); bsleep = GetObjectMember(oThdConf, "bsleep"); aff = GetObjectMember(oThdConf, "affine_to_cpu"); + syncMode = GetObjectMember(oThdConf, "sync_mode"); if(gid == nullptr || blocks == nullptr || threads == nullptr || - bfactor == nullptr || bsleep == nullptr || aff == nullptr) + bfactor == nullptr || bsleep == nullptr || aff == nullptr || syncMode == nullptr) { return false; } @@ -155,11 +156,17 @@ bool jconf::GetGPUThreadConfig(size_t id, thd_cfg &cfg) if(!aff->IsUint64() && !aff->IsBool()) return false; + if(!syncMode->IsNumber() || syncMode->GetInt() < 0 || syncMode->GetInt() > 3) + { + printer::inst()->print_msg(L0, "Error NVIDIA: sync_mode out of range or no number. ( range: 0 <= sync_mode < 4.)"); + return false; + } cfg.id = gid->GetInt(); cfg.blocks = blocks->GetInt(); cfg.threads = threads->GetInt(); cfg.bfactor = bfactor->GetInt(); cfg.bsleep = bsleep->GetInt(); + cfg.syncMode = syncMode->GetInt(); if(aff->IsNumber()) cfg.cpu_aff = aff->GetInt(); diff --git a/xmrstak/backend/nvidia/jconf.hpp b/xmrstak/backend/nvidia/jconf.hpp index b09a162..7f60f1d 100644 --- a/xmrstak/backend/nvidia/jconf.hpp +++ b/xmrstak/backend/nvidia/jconf.hpp @@ -28,6 +28,7 @@ public: bool bDoubleMode; bool bNoPrefetch; int32_t cpu_aff; + int syncMode; long long iCpuAff; }; diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index 9eab1c0..6e628fd 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -77,6 +77,7 @@ minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg) ctx.device_threads = (int)cfg.threads; ctx.device_bfactor = (int)cfg.bfactor; ctx.device_bsleep = (int)cfg.bsleep; + ctx.syncMode = cfg.syncMode; this->affinity = cfg.cpu_aff; std::unique_lock<std::mutex> lck(thd_aff_set); diff --git a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp index 1b63379..afbdbaf 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp +++ b/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp @@ -11,7 +11,8 @@ typedef struct { int device_blocks; int device_threads; int device_bfactor; - int device_bsleep; + int device_bsleep; + int syncMode; uint32_t *d_input; uint32_t inputlen; diff --git a/xmrstak/backend/nvidia/nvcc_code/cuda_core.cu b/xmrstak/backend/nvidia/nvcc_code/cuda_core.cu index dba6676..0b175b5 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cuda_core.cu +++ b/xmrstak/backend/nvidia/nvcc_code/cuda_core.cu @@ -327,18 +327,22 @@ void cryptonight_core_gpu_hash(nvid_ctx* ctx) for ( int i = 0; i < partcount; i++ ) { - CUDA_CHECK_KERNEL(ctx->device_id, cryptonight_core_gpu_phase2<ITERATIONS,THREAD_SHIFT,MASK><<< - grid, - block4, - block4.x * sizeof(uint32_t) * static_cast< int >( ctx->device_arch[0] < 3 ) - >>>( - ctx->device_blocks*ctx->device_threads, - ctx->device_bfactor, - i, - ctx->d_long_state, - ctx->d_ctx_a, - ctx->d_ctx_b - )); + CUDA_CHECK_MSG_KERNEL( + ctx->device_id, + "\n**suggestion: Try to increase the value of the attribute 'bfactor' or \nreduce 'threads' in the NVIDIA config file.**", + cryptonight_core_gpu_phase2<ITERATIONS,THREAD_SHIFT,MASK><<< + grid, + block4, + block4.x * sizeof(uint32_t) * static_cast< int >( ctx->device_arch[0] < 3 ) + >>>( + ctx->device_blocks*ctx->device_threads, + ctx->device_bfactor, + i, + ctx->d_long_state, + ctx->d_ctx_a, + ctx->d_ctx_b + ) + ); if ( partcount > 1 && ctx->device_bsleep > 0) compat_usleep( ctx->device_bsleep ); } diff --git a/xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp b/xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp index 078c165..563bb3b 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp +++ b/xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp @@ -9,22 +9,41 @@ /** execute and check a CUDA api command * * @param id gpu id (thread id) + * @param msg message string which should be added to the error message * @param ... CUDA api command */ -#define CUDA_CHECK(id, ...) { \ - cudaError_t error = __VA_ARGS__; \ - if(error!=cudaSuccess){ \ - std::cerr << "[CUDA] Error gpu " << id << ": <" << __FILE__ << ">:" << __LINE__ << std::endl; \ - throw std::runtime_error(std::string("[CUDA] Error: ") + std::string(cudaGetErrorString(error))); \ - } \ -} \ +#define CUDA_CHECK_MSG(id, msg, ...) { \ + cudaError_t error = __VA_ARGS__; \ + if(error!=cudaSuccess){ \ + std::cerr << "[CUDA] Error gpu " << id << ": <" << __FILE__ << ">:" << __LINE__; \ + std::cerr << msg << std::endl; \ + throw std::runtime_error(std::string("[CUDA] Error: ") + std::string(cudaGetErrorString(error))); \ + } \ +} \ ( (void) 0 ) +/** execute and check a CUDA api command + * + * @param id gpu id (thread id) + * @param ... CUDA api command + */ +#define CUDA_CHECK(id, ...) CUDA_CHECK_MSG(id, "", __VA_ARGS__) + /** execute and check a CUDA kernel * * @param id gpu id (thread id) * @param ... CUDA kernel call */ -#define CUDA_CHECK_KERNEL(id, ...) \ - __VA_ARGS__; \ +#define CUDA_CHECK_KERNEL(id, ...) \ + __VA_ARGS__; \ CUDA_CHECK(id, cudaGetLastError()) + +/** execute and check a CUDA kernel + * + * @param id gpu id (thread id) + * @param msg message string which should be added to the error message + * @param ... CUDA kernel call + */ +#define CUDA_CHECK_MSG_KERNEL(id, msg, ...) \ + __VA_ARGS__; \ + CUDA_CHECK_MSG(id, msg, cudaGetLastError()) diff --git a/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu b/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu index 333ae73..492201d 100644 --- a/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu +++ b/xmrstak/backend/nvidia/nvcc_code/cuda_extra.cu @@ -189,7 +189,22 @@ extern "C" int cryptonight_extra_cpu_init(nvid_ctx* ctx) } cudaDeviceReset(); - cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); + switch(ctx->syncMode) + { + case 0: + cudaSetDeviceFlags(cudaDeviceScheduleAuto); + break; + case 1: + cudaSetDeviceFlags(cudaDeviceScheduleSpin); + break; + case 2: + cudaSetDeviceFlags(cudaDeviceScheduleYield); + break; + case 3: + cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync); + break; + + }; cudaDeviceSetCacheConfig(cudaFuncCachePreferL1); size_t hashMemSize; @@ -203,7 +218,6 @@ extern "C" int cryptonight_extra_cpu_init(nvid_ctx* ctx) } size_t wsize = ctx->device_blocks * ctx->device_threads; - CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_long_state, hashMemSize * wsize)); CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_ctx_state, 50 * sizeof(uint32_t) * wsize)); CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_ctx_key1, 40 * sizeof(uint32_t) * wsize)); CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_ctx_key2, 40 * sizeof(uint32_t) * wsize)); @@ -213,6 +227,10 @@ extern "C" int cryptonight_extra_cpu_init(nvid_ctx* ctx) CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_input, 21 * sizeof (uint32_t ) )); CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_result_count, sizeof (uint32_t ) )); CUDA_CHECK(ctx->device_id, cudaMalloc(&ctx->d_result_nonce, 10 * sizeof (uint32_t ) )); + CUDA_CHECK_MSG( + ctx->device_id, + "\n**suggestion: Try to reduce the value of the attribute 'threads' in the NVIDIA config file.**", + cudaMalloc(&ctx->d_long_state, hashMemSize * wsize)); return 1; } @@ -239,7 +257,11 @@ extern "C" void cryptonight_extra_cpu_final(nvid_ctx* ctx, uint32_t startNonce, CUDA_CHECK(ctx->device_id, cudaMemset( ctx->d_result_nonce, 0xFF, 10 * sizeof (uint32_t ) )); CUDA_CHECK(ctx->device_id, cudaMemset( ctx->d_result_count, 0, sizeof (uint32_t ) )); - CUDA_CHECK_KERNEL(ctx->device_id, cryptonight_extra_gpu_final<<<grid, block >>>( wsize, target, ctx->d_result_count, ctx->d_result_nonce, ctx->d_ctx_state )); + CUDA_CHECK_MSG_KERNEL( + ctx->device_id, + "\n**suggestion: Try to increase the value of the attribute 'bfactor' in the NVIDIA config file.**", + cryptonight_extra_gpu_final<<<grid, block >>>( wsize, target, ctx->d_result_count, ctx->d_result_nonce, ctx->d_ctx_state ) + ); CUDA_CHECK(ctx->device_id, cudaMemcpy( rescount, ctx->d_result_count, sizeof (uint32_t ), cudaMemcpyDeviceToHost )); CUDA_CHECK(ctx->device_id, cudaMemcpy( resnonce, ctx->d_result_nonce, 10 * sizeof (uint32_t ), cudaMemcpyDeviceToHost )); diff --git a/xmrstak/cli/cli-miner.cpp b/xmrstak/cli/cli-miner.cpp index e32733b..546d226 100644 --- a/xmrstak/cli/cli-miner.cpp +++ b/xmrstak/cli/cli-miner.cpp @@ -66,6 +66,9 @@ void help() cout<<" -v, --version show version number"<<endl; cout<<" -V, --version-long show long version number"<<endl; cout<<" -c, --config FILE common miner configuration file"<<endl; +#ifdef _WIN32 + cout<<" --noUAC disable the UAC dialog"<<endl; +#endif #if (!defined(CONF_NO_AEON)) && (!defined(CONF_NO_MONERO)) cout<<" --currency NAME currency to mine: monero or aeon"<<endl; #endif @@ -82,7 +85,7 @@ void help() cout<<" --nvidia FILE NVIDIA backend miner config file"<<endl; #endif cout<<" "<<endl; - cout<<"The Following options temporary overwrites the config file settings:"<<endl; + cout<<"The Following options temporary overwrites the config entries of \nthe pool with the highest weight:"<<endl; cout<<" -o, --url URL pool url and port, e.g. pool.usxmrpool.com:3333"<<endl; cout<<" -u, --user USERNAME pool user name or wallet address"<<endl; cout<<" -p, --pass PASSWD pool password, in the most cases x or empty \"\""<<endl; @@ -269,6 +272,41 @@ void do_guided_config(bool userSetPasswd) std::cout<<"Configuration stored in file '"<<params::inst().configFile<<"'"<<std::endl; } +#ifdef _WIN32 +/** start the miner as administrator + * + * This function based on the stackoverflow post + * - source: https://stackoverflow.com/a/4893508 + * - author: Cody Gray + * - date: Feb 4 '11 + */ +void UACDialog(const std::string& binaryName, std::string& args) +{ + args += " --noUAC"; + SHELLEXECUTEINFO shExInfo = {0}; + shExInfo.cbSize = sizeof(shExInfo); + shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + shExInfo.hwnd = 0; + shExInfo.lpVerb = "runas"; + shExInfo.lpFile = binaryName.c_str(); + // disable UAC dialog (else the miner will go into a infinite loop) + shExInfo.lpParameters = args.c_str(); + shExInfo.lpDirectory = 0; + shExInfo.nShow = SW_SHOW; + shExInfo.hInstApp = 0; + + if(ShellExecuteEx(&shExInfo)) + { + printer::inst()->print_msg(L0, + "This window has been opened because xmr-stak needed to run as administrator. It can be safely closed now."); + WaitForSingleObject(shExInfo.hProcess, INFINITE); + CloseHandle(shExInfo.hProcess); + // do not start the miner twice + std::exit(0); + } +} +#endif + int main(int argc, char *argv[]) { #ifndef CONF_NO_TLS @@ -302,6 +340,7 @@ int main(int argc, char *argv[]) } bool userSetPasswd = false; + bool uacDialog = true; for(int i = 1; i < argc; ++i) { std::string opName(argv[i]); @@ -424,6 +463,10 @@ int main(int argc, char *argv[]) } params::inst().configFile = argv[i]; } + else if(opName.compare("--noUAC") == 0) + { + uacDialog = false; + } else { printer::inst()->print_msg(L0, "Parameter unknown '%s'",argv[i]); @@ -432,6 +475,20 @@ int main(int argc, char *argv[]) } } +#ifdef _WIN32 + if(uacDialog) + { + std::string minerArgs; + for(int i = 1; i < argc; i++) + { + minerArgs += " "; + minerArgs += argv[i]; + } + + UACDialog(argv[0], minerArgs); + } +#endif + // check if we need a guided start if(!configEditor::file_exist(params::inst().configFile)) do_guided_config(userSetPasswd); diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index c500b21..6f34d80 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -528,6 +528,30 @@ void executor::ex_main() pools.emplace_front(0, "donate.xmr-stak.net:4444", "", "", 0.0, true, false, "", true); } + /* find the pool with the highest weighting to allow overwriting of the + * pool settings via command line options. + */ + std::vector<jpsock*> sorted_pools; + sorted_pools.reserve(pools.size()); + for(jpsock& pool : pools) + sorted_pools.emplace_back(&pool); + std::sort(sorted_pools.begin(), sorted_pools.end(), [](jpsock* a, jpsock* b) { return b->get_pool_weight(true) < a->get_pool_weight(true); }); + + // overwrite pool address if cli option is used + auto& poolURL = xmrstak::params::inst().poolURL; + if(!poolURL.empty()) + { + sorted_pools[0]->set_pool_addr(poolURL.c_str()); + } + // overwrite user pool login name if cli option is used + auto& poolUsername = xmrstak::params::inst().poolUsername; + if(!poolUsername.empty()) + sorted_pools[0]->set_user_login(poolUsername.c_str()); + // overwrite user pool login password if cli option is used + auto& poolPasswd = xmrstak::params::inst().poolPasswd; + if(!poolPasswd.empty()) + sorted_pools[0]->set_user_passwd(poolPasswd.c_str()); + ex_event ev; std::thread clock_thd(&executor::ex_clock_thd, this); diff --git a/xmrstak/net/jpsock.hpp b/xmrstak/net/jpsock.hpp index 9d276b7..ba5d1c8 100644 --- a/xmrstak/net/jpsock.hpp +++ b/xmrstak/net/jpsock.hpp @@ -59,6 +59,10 @@ public: inline const char* get_tls_fp() { return tls_fp.c_str(); } inline bool is_nicehash() { return nicehash; } + inline void set_pool_addr(const char* sAddr) { net_addr = sAddr; } + inline void set_user_login(const char* sLogin) { usr_login = sLogin; } + inline void set_user_passwd(const char* sPassword) { usr_pass = sPassword; } + bool get_pool_motd(std::string& strin); std::string&& get_call_error(); |