summaryrefslogtreecommitdiffstats
path: root/xmrstak
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-11-16 12:12:40 +0100
committerGitHub <noreply@github.com>2017-11-16 12:12:40 +0100
commit1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a (patch)
treebbebd1f9969dbd09283fba5cb3ef9fc170dc0400 /xmrstak
parent2c3a3484757f242cf20b8e2ca2d89cfe01f64888 (diff)
parent41eb0ad64e6d003368ccf8f3212f190a829aae10 (diff)
downloadxmr-stak-1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a.zip
xmr-stak-1dc874c542a23c36dd65ea0f5b9cb65e3c3a572a.tar.gz
Merge pull request #115 from fireice-uk/topic-net-ext
Network extensions
Diffstat (limited to 'xmrstak')
-rw-r--r--xmrstak/backend/amd/minethd.cpp2
-rw-r--r--xmrstak/backend/cpu/minethd.cpp8
-rw-r--r--xmrstak/backend/iBackend.hpp27
-rw-r--r--xmrstak/backend/nvidia/minethd.cpp2
-rw-r--r--xmrstak/config.tpl3
-rw-r--r--xmrstak/http/webdesign.cpp23
-rw-r--r--xmrstak/http/webdesign.hpp4
-rw-r--r--xmrstak/jconf.cpp10
-rw-r--r--xmrstak/jconf.hpp1
-rw-r--r--xmrstak/misc/executor.cpp103
-rw-r--r--xmrstak/misc/executor.hpp4
-rw-r--r--xmrstak/net/jpsock.cpp79
-rw-r--r--xmrstak/net/jpsock.hpp13
-rw-r--r--xmrstak/net/msgstruct.hpp3
14 files changed, 251 insertions, 31 deletions
diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp
index 94fc088..de0b6e8 100644
--- a/xmrstak/backend/amd/minethd.cpp
+++ b/xmrstak/backend/amd/minethd.cpp
@@ -241,7 +241,7 @@ void minethd::work_main()
hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx);
if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult, iThreadNo), oWork.iPoolId));
else
executor::inst()->push_event(ex_event("AMD Invalid Result", oWork.iPoolId));
}
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp
index 8183adf..03071c4 100644
--- a/xmrstak/backend/cpu/minethd.cpp
+++ b/xmrstak/backend/cpu/minethd.cpp
@@ -358,7 +358,8 @@ void minethd::work_main()
piHashVal = (uint64_t*)(result.bResult + 24);
piNonce = (uint32_t*)(oWork.bWorkBlob + 39);
globalStates::inst().inst().iConsumeCnt++;
-
+ result.iThreadId = iThreadNo;
+
while (bQuit == 0)
{
if (oWork.bStall)
@@ -542,17 +543,16 @@ void minethd::double_work_main()
globalStates::inst().calc_start_nonce(iNonce, oWork.bNiceHash, nonce_chunk);
}
-
*piNonce0 = ++iNonce;
*piNonce1 = ++iNonce;
hash_fun(bDoubleWorkBlob, oWork.iWorkSize, bDoubleHashOut, ctx0, ctx1);
if (*piHashVal0 < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce-1, bDoubleHashOut), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce-1, bDoubleHashOut, iThreadNo), oWork.iPoolId));
if (*piHashVal1 < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce, bDoubleHashOut + 32), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce, bDoubleHashOut + 32, iThreadNo), oWork.iPoolId));
std::this_thread::yield();
}
diff --git a/xmrstak/backend/iBackend.hpp b/xmrstak/backend/iBackend.hpp
index dbfbc99..3d2115a 100644
--- a/xmrstak/backend/iBackend.hpp
+++ b/xmrstak/backend/iBackend.hpp
@@ -8,22 +8,33 @@
#include <vector>
#include <string>
+template <typename T, std::size_t N>
+constexpr std::size_t countof(T const (&)[N]) noexcept
+{
+ return N;
+}
+
namespace xmrstak
{
struct iBackend
{
- enum BackendType : uint32_t { UNKNOWN = 0, CPU = 1u, AMD = 2u, NVIDIA = 3u };
+ enum BackendType : uint32_t { UNKNOWN = 0u, CPU = 1u, AMD = 2u, NVIDIA = 3u };
- static std::string getName(const BackendType type)
+ static const char* getName(const BackendType type)
{
- std::vector<std::string> backendNames = {
- "UNKNOWN",
- "CPU",
- "AMD",
- "NVIDIA"
+ const char* backendNames[] = {
+ "unknown",
+ "cpu",
+ "amd",
+ "nvidia"
};
- return backendNames[static_cast<uint32_t>(type)];
+
+ uint32_t i = static_cast<uint32_t>(type);
+ if(i >= countof(backendNames))
+ i = 0;
+
+ return backendNames[i];
}
std::atomic<uint64_t> iHashCount;
diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp
index 4d9efd2..9dbd83e 100644
--- a/xmrstak/backend/nvidia/minethd.cpp
+++ b/xmrstak/backend/nvidia/minethd.cpp
@@ -283,7 +283,7 @@ void minethd::work_main()
hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx);
if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget)
- executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult), oWork.iPoolId));
+ executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult, iThreadNo), oWork.iPoolId));
else
executor::inst()->push_event(ex_event("NVIDIA Invalid Result", oWork.iPoolId));
}
diff --git a/xmrstak/config.tpl b/xmrstak/config.tpl
index c3ea061..ae97190 100644
--- a/xmrstak/config.tpl
+++ b/xmrstak/config.tpl
@@ -51,8 +51,11 @@ POOLCONF],
* 2 - All of level 1, and new job (block) event if the difficulty is different from the last job
* 3 - All of level 1, and new job (block) event in all cases, result submission event.
* 4 - All of level 3, and automatic hashrate report printing
+ *
+ * print_motd - Display messages from your pool operator in the hashrate result.
*/
"verbose_level" : 3,
+"print_motd" : true,
/*
* Automatic hashrate report
diff --git a/xmrstak/http/webdesign.cpp b/xmrstak/http/webdesign.cpp
index 3c33e1f..963c080 100644
--- a/xmrstak/http/webdesign.cpp
+++ b/xmrstak/http/webdesign.cpp
@@ -1,6 +1,6 @@
#include <stdlib.h>
-extern const char sHtmlCssEtag [] = "00000008";
+extern const char sHtmlCssEtag [] = "00000009";
extern const char sHtmlCssFile [] =
"body {"
"font-family: Tahoma, Arial, sans-serif;"
@@ -92,6 +92,23 @@ extern const char sHtmlCssFile [] =
".flex-item {"
"width: 33%;"
"margin: 3px;"
+ "}"
+
+ ".motd-box {"
+ "background-color: #ccc;"
+ "padding: 0px 10px 5px 10px;"
+ "margin-bottom: 10px;"
+ "}"
+
+ ".motd-head {"
+ "border-bottom: 1px solid #000;"
+ "margin-bottom: 0.5em;"
+ "padding: 0.5em 0em;"
+ "font-weight: bold;"
+ "}"
+
+ ".motd-body {"
+ "overflow: hidden;"
"}";
size_t sHtmlCssSize = sizeof(sHtmlCssFile) - 1;
@@ -130,6 +147,10 @@ extern const char sHtmlCommonHeader [] =
"</div>"
"<h4>%s</h4>";
+extern const char sHtmlMotdBoxStart[] = "<div class='motd-box'>";
+extern const char sHtmlMotdEntry[] = "<div class='motd-head'>Message from %s</div><div class='motd-body'>%s</div>";
+extern const char sHtmlMotdBoxEnd[] = "</div>";
+
extern const char sHtmlHashrateBodyHigh [] =
"<div class=data>"
"<table>"
diff --git a/xmrstak/http/webdesign.hpp b/xmrstak/http/webdesign.hpp
index 122b5fb..48adfea 100644
--- a/xmrstak/http/webdesign.hpp
+++ b/xmrstak/http/webdesign.hpp
@@ -12,6 +12,10 @@ extern const char sHttpAuthOpaque[];
extern const char sHtmlCommonHeader[];
+extern const char sHtmlMotdBoxStart[];
+extern const char sHtmlMotdEntry[];
+extern const char sHtmlMotdBoxEnd[];
+
extern const char sHtmlHashrateBodyHigh[];
extern const char sHtmlHashrateTableRow[];
extern const char sHtmlHashrateBodyLow[];
diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp
index 6d0f8ae..a617f96 100644
--- a/xmrstak/jconf.cpp
+++ b/xmrstak/jconf.cpp
@@ -51,7 +51,7 @@ using namespace rapidjson;
* This enum needs to match index in oConfigValues, otherwise we will get a runtime error
*/
enum configEnum {
- aPoolList, bTlsSecureAlgo, sCurrency, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime,
+ aPoolList, bTlsSecureAlgo, sCurrency, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, bPrintMotd, iAutohashTime,
bFlushStdout, bDaemonMode, sOutputFile, iHttpdPort, sHttpLogin, sHttpPass, bPreferIpv4, bAesOverride, sUseSlowMem
};
@@ -71,6 +71,7 @@ configVal oConfigValues[] = {
{ iNetRetry, "retry_time", kNumberType },
{ iGiveUpLimit, "giveup_limit", kNumberType },
{ iVerboseLevel, "verbose_level", kNumberType },
+ { bPrintMotd, "print_motd", kTrueType },
{ iAutohashTime, "h_print_time", kNumberType },
{ bFlushStdout, "flush_stdout", kTrueType},
{ bDaemonMode, "daemon_mode", kTrueType },
@@ -193,7 +194,7 @@ const std::string jconf::GetCurrency()
bool jconf::IsCurrencyMonero()
{
- if(xmrstak::strcmp_i(::jconf::inst()->GetCurrency(), "monero"))
+ if(xmrstak::strcmp_i(GetCurrency(), "monero"))
{
return true;
}
@@ -228,6 +229,11 @@ uint64_t jconf::GetVerboseLevel()
return prv->configValues[iVerboseLevel]->GetUint64();
}
+bool jconf::PrintMotd()
+{
+ return prv->configValues[bPrintMotd]->GetBool();
+}
+
uint64_t jconf::GetAutohashTime()
{
return prv->configValues[iAutohashTime]->GetUint64();
diff --git a/xmrstak/jconf.hpp b/xmrstak/jconf.hpp
index 1bd4d47..131263e 100644
--- a/xmrstak/jconf.hpp
+++ b/xmrstak/jconf.hpp
@@ -51,6 +51,7 @@ public:
bool IsCurrencyMonero();
uint64_t GetVerboseLevel();
+ bool PrintMotd();
uint64_t GetAutohashTime();
const char* GetOutputFile();
diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp
index 4a3a77b..43e3d6b 100644
--- a/xmrstak/misc/executor.cpp
+++ b/xmrstak/misc/executor.cpp
@@ -400,12 +400,13 @@ void executor::on_pool_have_job(size_t pool_id, pool_job& oPoolJob)
void executor::on_miner_result(size_t pool_id, job_result& oResult)
{
jpsock* pool = pick_pool_by_id(pool_id);
+ bool is_monero = jconf::inst()->IsCurrencyMonero();
if(pool->is_dev_pool())
{
//Ignore errors silently
if(pool->is_running() && pool->is_logged_in())
- pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult);
+ pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, pvThreads->at(oResult.iThreadId), is_monero);
return;
}
@@ -418,7 +419,7 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult)
using namespace std::chrono;
size_t t_start = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
- bool bResult = pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult);
+ bool bResult = pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, pvThreads->at(oResult.iThreadId), is_monero);
size_t t_len = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count() - t_start;
if(t_len > 0xFFFF)
@@ -630,8 +631,75 @@ inline const char* hps_format(double h, char* buf, size_t l)
return " (na)";
}
+bool executor::motd_filter_console(std::string& motd)
+{
+ if(motd.size() > motd_max_length)
+ return false;
+
+ motd.erase(std::remove_if(motd.begin(), motd.end(), [](int chr)->bool { return !((chr >= 0x20 && chr <= 0x7e) || chr == '\n');}), motd.end());
+ return motd.size() > 0;
+}
+
+bool executor::motd_filter_web(std::string& motd)
+{
+ if(!motd_filter_console(motd))
+ return false;
+
+ std::string tmp;
+ tmp.reserve(motd.size() + 128);
+
+ for(size_t i=0; i < motd.size(); i++)
+ {
+ char c = motd[i];
+ switch(c)
+ {
+ case '&':
+ tmp.append("&amp;");
+ break;
+ case '"':
+ tmp.append("&quot;");
+ break;
+ case '\'':
+ tmp.append("&#039");
+ break;
+ case '<':
+ tmp.append("&lt;");
+ break;
+ case '>':
+ tmp.append("&gt;");
+ break;
+ case '\n':
+ tmp.append("<br>");
+ break;
+ default:
+ tmp.append(1, c);
+ break;
+ }
+ }
+
+ motd = std::move(tmp);
+ return true;
+}
+
void executor::hashrate_report(std::string& out)
{
+ out.reserve(2048 + pvThreads->size() * 64);
+
+ if(jconf::inst()->PrintMotd())
+ {
+ std::string motd;
+ for(jpsock& pool : pools)
+ {
+ motd.empty();
+ if(pool.get_pool_motd(motd) && motd_filter_console(motd))
+ {
+ out.append("Message from ").append(pool.get_pool_addr()).append(":\n");
+ out.append(motd).append("\n");
+ out.append("-----------------------------------------------------\n");
+ }
+ }
+ }
+
char num[32];
double fTotal[3] = { 0.0, 0.0, 0.0};
@@ -648,11 +716,12 @@ void executor::hashrate_report(std::string& out)
size_t nthd = backEnds.size();
if(nthd != 0)
{
- out.reserve(256 + nthd * 64);
-
size_t i;
auto bType = static_cast<xmrstak::iBackend::BackendType>(b);
- out.append("HASHRATE REPORT - ").append(xmrstak::iBackend::getName(bType)).append("\n");
+ std::string name(xmrstak::iBackend::getName(bType));
+ std::transform(name.begin(), name.end(), name.begin(), ::toupper);
+
+ out.append("HASHRATE REPORT - ").append(name).append("\n");
out.append("| ID | 10s | 60s | 15m |");
if(nthd != 1)
out.append(" ID | 10s | 60s | 15m |\n");
@@ -864,6 +933,30 @@ void executor::http_hashrate_report(std::string& out)
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Hashrate Report", ver_html, "Hashrate Report");
out.append(buffer);
+ bool have_motd = false;
+ if(jconf::inst()->PrintMotd())
+ {
+ std::string motd;
+ for(jpsock& pool : pools)
+ {
+ motd.empty();
+ if(pool.get_pool_motd(motd) && motd_filter_web(motd))
+ {
+ if(!have_motd)
+ {
+ out.append(sHtmlMotdBoxStart);
+ have_motd = true;
+ }
+
+ snprintf(buffer, sizeof(buffer), sHtmlMotdEntry, pool.get_pool_addr(), motd.c_str());
+ out.append(buffer);
+ }
+ }
+ }
+
+ if(have_motd)
+ out.append(sHtmlMotdBoxEnd);
+
snprintf(buffer, sizeof(buffer), sHtmlHashrateBodyHigh, (unsigned int)nthd + 3);
out.append(buffer);
diff --git a/xmrstak/misc/executor.hpp b/xmrstak/misc/executor.hpp
index 9ff0323..c90e864 100644
--- a/xmrstak/misc/executor.hpp
+++ b/xmrstak/misc/executor.hpp
@@ -94,6 +94,10 @@ private:
void ex_clock_thd();
void pool_connect(jpsock* pool);
+ constexpr static size_t motd_max_length = 512;
+ bool motd_filter_console(std::string& motd);
+ bool motd_filter_web(std::string& motd);
+
void hashrate_report(std::string& out);
void result_report(std::string& out);
void connection_report(std::string& out);
diff --git a/xmrstak/net/jpsock.cpp b/xmrstak/net/jpsock.cpp
index cb586d2..5769448 100644
--- a/xmrstak/net/jpsock.cpp
+++ b/xmrstak/net/jpsock.cpp
@@ -23,6 +23,7 @@
#include <stdarg.h>
#include <assert.h>
+#include <algorithm>
#include "jpsock.hpp"
#include "socks.hpp"
@@ -33,9 +34,6 @@
#include "xmrstak/misc/jext.hpp"
#include "xmrstak/version.hpp"
-
-#define AGENTID_STR XMR_STAK_NAME "/" XMR_STAK_VERSION
-
using namespace rapidjson;
struct jpsock::call_rsp
@@ -366,10 +364,11 @@ bool jpsock::process_pool_job(const opq_json_val* params)
if (!params->val->IsObject())
return set_socket_error("PARSE error: Job error 1");
- const Value * blob, *jobid, *target;
+ const Value *blob, *jobid, *target, *motd;
jobid = GetObjectMember(*params->val, "job_id");
blob = GetObjectMember(*params->val, "blob");
target = GetObjectMember(*params->val, "target");
+ motd = GetObjectMember(*params->val, "motd");
if (jobid == nullptr || blob == nullptr || target == nullptr ||
!jobid->IsString() || !blob->IsString() || !target->IsString())
@@ -415,6 +414,19 @@ bool jpsock::process_pool_job(const opq_json_val* params)
else
return set_socket_error("PARSE error: Job error 5");
+ if(motd != nullptr && motd->IsString() && (motd->GetStringLength() & 0x01) == 0)
+ {
+ std::unique_lock<std::mutex>(motd_mutex);
+ if(motd->GetStringLength() > 0)
+ {
+ pool_motd.resize(motd->GetStringLength()/2 + 1);
+ if(!hex2bin(motd->GetString(), motd->GetStringLength(), (unsigned char*)&pool_motd.front()))
+ pool_motd.clear();
+ }
+ else
+ pool_motd.clear();
+ }
+
iJobDiff = t64_to_diff(oPoolJob.iTarget);
executor::inst()->push_event(ex_event(oPoolJob, pool_id));
@@ -426,6 +438,7 @@ bool jpsock::process_pool_job(const opq_json_val* params)
bool jpsock::connect(std::string& sConnectError)
{
+ ext_algo = ext_backend = ext_hashcount = ext_motd = false;
bHaveSocketError = false;
sSocketError.clear();
iJobDiff = 0;
@@ -527,6 +540,7 @@ bool jpsock::cmd_login()
const Value* id = GetObjectMember(*oResult.val, "id");
const Value* job = GetObjectMember(*oResult.val, "job");
+ const Value* ext = GetObjectMember(*oResult.val, "extensions");
if (id == nullptr || job == nullptr || !id->IsString())
{
@@ -545,6 +559,29 @@ bool jpsock::cmd_login()
memset(sMinerId, 0, sizeof(sMinerId));
memcpy(sMinerId, id->GetString(), id->GetStringLength());
+ if(ext != nullptr && ext->IsArray())
+ {
+ for(size_t i=0; i < ext->Size(); i++)
+ {
+ const Value& jextname = ext->GetArray()[i];
+
+ if(!jextname.IsString())
+ continue;
+
+ std::string tmp(jextname.GetString());
+ std::transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower);
+
+ if(tmp == "algo")
+ ext_algo = true;
+ else if(tmp == "backend")
+ ext_backend = true;
+ else if(tmp == "hashcount")
+ ext_hashcount = true;
+ else if(tmp == "motd")
+ ext_motd = true;
+ }
+ }
+
opq_json_val v(job);
if(!process_pool_job(&v))
{
@@ -558,20 +595,33 @@ bool jpsock::cmd_login()
return true;
}
-bool jpsock::cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bResult)
+bool jpsock::cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bResult, xmrstak::iBackend* bend, bool algo_full_cn)
{
char cmd_buffer[1024];
char sNonce[9];
char sResult[65];
+ /*Extensions*/
+ char sAlgo[64] = {0};
+ char sBackend[64] = {0};
+ char sHashcount[64] = {0};
+ if(ext_backend)
+ snprintf(sBackend, sizeof(sBackend), ",\"backend\":\"%s\"", xmrstak::iBackend::getName(bend->backendType));
+
+ if(ext_hashcount)
+ snprintf(sHashcount, sizeof(sHashcount), ",\"hashcount\":%llu", int_port(bend->iHashCount.load(std::memory_order_relaxed)));
+
+ if(ext_algo)
+ snprintf(sAlgo, sizeof(sAlgo), ",\"algo\":\"%s\"", algo_full_cn ? "cryptonight" : "cryptonight-lite");
+
bin2hex((unsigned char*)&iNonce, 4, sNonce);
sNonce[8] = '\0';
bin2hex(bResult, 32, sResult);
sResult[64] = '\0';
- snprintf(cmd_buffer, sizeof(cmd_buffer), "{\"method\":\"submit\",\"params\":{\"id\":\"%s\",\"job_id\":\"%s\",\"nonce\":\"%s\",\"result\":\"%s\"},\"id\":1}\n",
- sMinerId, sJobId, sNonce, sResult);
+ snprintf(cmd_buffer, sizeof(cmd_buffer), "{\"method\":\"submit\",\"params\":{\"id\":\"%s\",\"job_id\":\"%s\",\"nonce\":\"%s\",\"result\":\"%s\"%s%s%s},\"id\":1}\n",
+ sMinerId, sJobId, sNonce, sResult, sBackend, sHashcount, sAlgo);
opq_json_val oResult(nullptr);
return cmd_ret_wait(cmd_buffer, oResult);
@@ -594,6 +644,21 @@ bool jpsock::get_current_job(pool_job& job)
return true;
}
+bool jpsock::get_pool_motd(std::string& strin)
+{
+ if(!ext_motd)
+ return false;
+
+ std::unique_lock<std::mutex>(motd_mutex);
+ if(pool_motd.size() > 0)
+ {
+ strin.assign(pool_motd);
+ return true;
+ }
+
+ return false;
+}
+
inline unsigned char hf_hex2bin(char c, bool &err)
{
if (c >= '0' && c <= '9')
diff --git a/xmrstak/net/jpsock.hpp b/xmrstak/net/jpsock.hpp
index db8cd0e..9d276b7 100644
--- a/xmrstak/net/jpsock.hpp
+++ b/xmrstak/net/jpsock.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "xmrstak/backend/iBackend.hpp"
#include "msgstruct.hpp"
#include <mutex>
@@ -33,7 +34,7 @@ public:
void disconnect(bool quiet = false);
bool cmd_login();
- bool cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bResult);
+ bool cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bResult, xmrstak::iBackend* bend, bool algo_full_cn);
static bool hex2bin(const char* in, unsigned int len, unsigned char* out);
static void bin2hex(const unsigned char* in, unsigned int len, char* out);
@@ -58,6 +59,8 @@ public:
inline const char* get_tls_fp() { return tls_fp.c_str(); }
inline bool is_nicehash() { return nicehash; }
+ bool get_pool_motd(std::string& strin);
+
std::string&& get_call_error();
bool have_sock_error() { return bHaveSocketError; }
@@ -87,6 +90,14 @@ private:
bool pool;
bool nicehash;
+ bool ext_algo = false;
+ bool ext_backend = false;
+ bool ext_hashcount = false;
+ bool ext_motd = false;
+
+ std::string pool_motd;
+ std::mutex motd_mutex;
+
size_t connect_time = 0;
std::atomic<size_t> connect_attempts;
std::atomic<size_t> disconnect_time;
diff --git a/xmrstak/net/msgstruct.hpp b/xmrstak/net/msgstruct.hpp
index 4d8d845..9065fe3 100644
--- a/xmrstak/net/msgstruct.hpp
+++ b/xmrstak/net/msgstruct.hpp
@@ -30,9 +30,10 @@ struct job_result
uint8_t bResult[32];
char sJobID[64];
uint32_t iNonce;
+ uint32_t iThreadId;
job_result() {}
- job_result(const char* sJobID, uint32_t iNonce, const uint8_t* bResult) : iNonce(iNonce)
+ job_result(const char* sJobID, uint32_t iNonce, const uint8_t* bResult, uint32_t iThreadId) : iNonce(iNonce), iThreadId(iThreadId)
{
memcpy(this->sJobID, sJobID, sizeof(job_result::sJobID));
memcpy(this->bResult, bResult, sizeof(job_result::bResult));
OpenPOWER on IntegriCloud