diff options
Diffstat (limited to 'xmrstak/misc')
-rw-r--r-- | xmrstak/misc/coinDescription.hpp | 60 | ||||
-rw-r--r-- | xmrstak/misc/configEditor.hpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/console.cpp | 4 | ||||
-rw-r--r-- | xmrstak/misc/console.hpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/environment.hpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/executor.cpp | 10 | ||||
-rw-r--r-- | xmrstak/misc/executor.hpp | 6 | ||||
-rw-r--r-- | xmrstak/misc/telemetry.cpp | 6 | ||||
-rw-r--r-- | xmrstak/misc/telemetry.hpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/utility.cpp | 2 | ||||
-rw-r--r-- | xmrstak/misc/utility.hpp | 2 |
11 files changed, 81 insertions, 17 deletions
diff --git a/xmrstak/misc/coinDescription.hpp b/xmrstak/misc/coinDescription.hpp new file mode 100644 index 0000000..73d9a95 --- /dev/null +++ b/xmrstak/misc/coinDescription.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include "xmrstak/backend/cryptonight.hpp" + +#include <stdlib.h> +#include <string> + + +namespace xmrstak +{ + struct coinDescription + { + xmrstak_algo algo; + xmrstak_algo algo_root; + uint8_t fork_version; + + coinDescription() = default; + + coinDescription(const xmrstak_algo in_algo, xmrstak_algo in_algo_root, const uint8_t in_fork_version) : + algo(in_algo), algo_root(in_algo_root), fork_version(in_fork_version) + {} + + inline xmrstak_algo GetMiningAlgo() const { return algo; } + inline xmrstak_algo GetMiningAlgoRoot() const { return algo_root; } + inline uint8_t GetMiningForkVersion() const { return fork_version; } + }; + + struct coin_selection + { + const char* coin_name = nullptr; + /* [0] -> user pool + * [1] -> dev pool + */ + coinDescription pool_coin[2]; + const char* default_pool = nullptr; + + coin_selection() = default; + + coin_selection( + const char* in_coin_name, + const coinDescription user_coinDescription, + const coinDescription dev_coinDescription, + const char* in_default_pool + ) : + coin_name(in_coin_name), default_pool(in_default_pool) + { + pool_coin[0] = user_coinDescription; + pool_coin[1] = dev_coinDescription; + } + + /** get coin description for the pool + * + * @param poolId 0 select dev pool, else the user pool is selected + */ + inline coinDescription GetDescription(size_t poolId) const { + coinDescription tmp = (poolId == 0 ? pool_coin[1] : pool_coin[0]); + return tmp; + } + }; +} // namespace xmrstak diff --git a/xmrstak/misc/configEditor.hpp b/xmrstak/misc/configEditor.hpp index a840bc4..8a81ad6 100644 --- a/xmrstak/misc/configEditor.hpp +++ b/xmrstak/misc/configEditor.hpp @@ -54,4 +54,4 @@ struct configEditor }; -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/misc/console.cpp b/xmrstak/misc/console.cpp index de5eed3..d961b71 100644 --- a/xmrstak/misc/console.cpp +++ b/xmrstak/misc/console.cpp @@ -225,7 +225,7 @@ void printer::print_str(const char* str) //Do a press any key for the windows folk. *insert any key joke here* #ifdef _WIN32 -void win_exit(size_t code) +void win_exit(int code) { size_t envSize = 0; getenv_s(&envSize, nullptr, 0, "XMRSTAK_NOWAIT"); @@ -238,7 +238,7 @@ void win_exit(size_t code) } #else -void win_exit(size_t code) +void win_exit(int code) { std::exit(code); } diff --git a/xmrstak/misc/console.hpp b/xmrstak/misc/console.hpp index cfbeddd..6717631 100644 --- a/xmrstak/misc/console.hpp +++ b/xmrstak/misc/console.hpp @@ -49,4 +49,4 @@ private: FILE* logfile; }; -void win_exit(size_t code = 1); +void win_exit(int code = 1); diff --git a/xmrstak/misc/environment.hpp b/xmrstak/misc/environment.hpp index 99c2db8..b67c858 100644 --- a/xmrstak/misc/environment.hpp +++ b/xmrstak/misc/environment.hpp @@ -38,4 +38,4 @@ struct environment params* pParams = nullptr; }; -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index 0e1dd9f..8c454eb 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -421,7 +421,9 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult) { //Ignore errors silently if(pool->is_running() && pool->is_logged_in()) - pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, backend_name, backend_hashcount, total_hashcount, jconf::inst()->GetMiningAlgo()); + pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, backend_name, + backend_hashcount, total_hashcount, jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo() + ); return; } @@ -432,7 +434,9 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult) } size_t t_start = get_timestamp_ms(); - bool bResult = pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, backend_name, backend_hashcount, total_hashcount, jconf::inst()->GetMiningAlgo()); + bool bResult = pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, + backend_name, backend_hashcount, total_hashcount, jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() + ); size_t t_len = get_timestamp_ms() - t_start; if(t_len > 0xFFFF) @@ -548,7 +552,7 @@ void executor::ex_main() pools.emplace_back(i+1, params.poolURL.c_str(), params.poolUsername.c_str(), params.poolRigid.c_str(), params.poolPasswd.c_str(), 9.9, false, params.poolUseTls, "", params.nicehashMode); } - switch(jconf::inst()->GetMiningAlgo()) + switch(jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo()) { case cryptonight_heavy: if(dev_tls) diff --git a/xmrstak/misc/executor.hpp b/xmrstak/misc/executor.hpp index fbaa265..be5ee6c 100644 --- a/xmrstak/misc/executor.hpp +++ b/xmrstak/misc/executor.hpp @@ -23,7 +23,7 @@ namespace cpu class minethd; } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak class executor { @@ -54,7 +54,7 @@ private: inline void set_timestamp() { dev_timestamp = get_timestamp(); }; - // In miliseconds, has to divide a second (1000ms) into an integer number + // In milliseconds, has to divide a second (1000ms) into an integer number constexpr static size_t iTickTime = 500; // Dev donation time period in seconds. 100 minutes by default. @@ -64,7 +64,7 @@ private: inline bool is_dev_time() { //Add 2 seconds to compensate for connect - constexpr size_t dev_portion = double(iDevDonatePeriod) * fDevDonationLevel + 2; + constexpr size_t dev_portion = static_cast<size_t>(double(iDevDonatePeriod) * fDevDonationLevel + 2.); if(dev_portion < 12) //No point in bothering with less than 10s return false; diff --git a/xmrstak/misc/telemetry.cpp b/xmrstak/misc/telemetry.cpp index 738d287..a3a2a12 100644 --- a/xmrstak/misc/telemetry.cpp +++ b/xmrstak/misc/telemetry.cpp @@ -89,8 +89,8 @@ double telemetry::calc_telemetry_data(size_t iLastMilisec, size_t iThread) return nan(""); double fHashes, fTime; - fHashes = iLastestHashCnt - iEarliestHashCnt; - fTime = iLastestStamp - iEarliestStamp; + fHashes = static_cast<double>(iLastestHashCnt - iEarliestHashCnt); + fTime = static_cast<double>(iLastestStamp - iEarliestStamp); fTime /= 1000.0; return fHashes / fTime; @@ -105,4 +105,4 @@ void telemetry::push_perf_value(size_t iThd, uint64_t iHashCount, uint64_t iTime iBucketTop[iThd] = (iTop + 1) & iBucketMask; } -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/misc/telemetry.hpp b/xmrstak/misc/telemetry.hpp index b35bbbf..2f84dfa 100644 --- a/xmrstak/misc/telemetry.hpp +++ b/xmrstak/misc/telemetry.hpp @@ -21,4 +21,4 @@ private: uint64_t** ppTimestamps; }; -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/misc/utility.cpp b/xmrstak/misc/utility.cpp index 3b1369a..5177d14 100644 --- a/xmrstak/misc/utility.cpp +++ b/xmrstak/misc/utility.cpp @@ -18,4 +18,4 @@ namespace xmrstak } ); } -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/misc/utility.hpp b/xmrstak/misc/utility.hpp index b2e841d..8f2e99f 100644 --- a/xmrstak/misc/utility.hpp +++ b/xmrstak/misc/utility.hpp @@ -9,4 +9,4 @@ namespace xmrstak * @return true if both strings are equal, else false */ bool strcmp_i(const std::string& str1, const std::string& str2); -} // namepsace xmrstak +} // namespace xmrstak |