summaryrefslogtreecommitdiffstats
path: root/xmrstak/misc
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/misc
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/misc')
-rw-r--r--xmrstak/misc/executor.cpp103
-rw-r--r--xmrstak/misc/executor.hpp4
2 files changed, 102 insertions, 5 deletions
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);
OpenPOWER on IntegriCloud