summaryrefslogtreecommitdiffstats
path: root/executor.h
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-29 20:32:31 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-30 23:46:08 +0200
commitcc429b68fadc502b981fd0acd64a5ff6e2ae1d15 (patch)
tree3fb23fc4db15dbdd08af4c7ea20134b9d82e58fd /executor.h
parente5b0319d5a9f58762fa934ad700113908940cb31 (diff)
downloadxmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.zip
xmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.tar.gz
group files
- move source code to `src` - categorize files and move to group folder - change upper case class files to lower case - change C++ header to `*.hpp`
Diffstat (limited to 'executor.h')
-rw-r--r--executor.h186
1 files changed, 0 insertions, 186 deletions
diff --git a/executor.h b/executor.h
deleted file mode 100644
index a3a0828..0000000
--- a/executor.h
+++ /dev/null
@@ -1,186 +0,0 @@
-#pragma once
-#include "thdq.hpp"
-#include "msgstruct.h"
-#include <atomic>
-#include <array>
-#include <list>
-#include <future>
-#include "telemetry.h"
-#include "backend/IBackend.hpp"
-#include "Environment.hpp"
-
-class jpsock;
-
-
-namespace xmrstak
-{
-namespace cpu
-{
-class minethd;
-
-} // namespace cpu
-} // namepsace xmrstak
-
-class executor
-{
-public:
- static executor* inst()
- {
- auto& env = xmrstak::Environment::inst();
- if(env.pExecutor == nullptr)
- env.pExecutor = new executor;
- return env.pExecutor;
- };
-
- void ex_start(bool daemon) { daemon ? ex_main() : std::thread(&executor::ex_main, this).detach(); }
-
- void get_http_report(ex_event_name ev_id, std::string& data);
-
- inline void push_event(ex_event&& ev) { oEventQ.push(std::move(ev)); }
- void push_timed_event(ex_event&& ev, size_t sec);
- void log_result_error(std::string&& sError);
-
- constexpr static size_t invalid_pool_id = 0;
- constexpr static size_t dev_pool_id = 1;
- constexpr static size_t usr_pool_id = 2;
-
-private:
- struct timed_event
- {
- ex_event event;
- size_t ticks_left;
-
- timed_event(ex_event&& ev, size_t ticks) : event(std::move(ev)), ticks_left(ticks) {}
- };
-
- // In miliseconds, 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.
- // We will divide up this period according to the config setting
- constexpr static size_t iDevDonatePeriod = 100 * 60;
-
- std::list<timed_event> lTimedEvents;
- std::mutex timed_event_mutex;
- thdq<ex_event> oEventQ;
-
- xmrstak::telemetry* telem;
- std::vector<xmrstak::IBackend*>* pvThreads;
-
- size_t current_pool_id;
-
- jpsock* usr_pool;
- jpsock* dev_pool;
-
- jpsock* pick_pool_by_id(size_t pool_id);
-
- bool is_dev_time;
-
- executor();
-
- void ex_main();
-
- void ex_clock_thd();
- void pool_connect(jpsock* pool);
-
- void hashrate_report(std::string& out);
- void result_report(std::string& out);
- void connection_report(std::string& out);
-
- void http_hashrate_report(std::string& out);
- void http_result_report(std::string& out);
- void http_connection_report(std::string& out);
- void http_json_report(std::string& out);
-
- void http_report(ex_event_name ev);
- void print_report(ex_event_name ev);
-
- std::string* pHttpString = nullptr;
- std::promise<void> httpReady;
- std::mutex httpMutex;
-
- size_t iReconnectAttempts = 0;
-
- struct sck_error_log
- {
- std::chrono::system_clock::time_point time;
- std::string msg;
-
- sck_error_log(std::string&& err) : msg(std::move(err))
- {
- time = std::chrono::system_clock::now();
- }
- };
- std::vector<sck_error_log> vSocketLog;
-
- // Element zero is always the success element.
- // Keep in mind that this is a tally and not a log like above
- struct result_tally
- {
- std::chrono::system_clock::time_point time;
- std::string msg;
- size_t count;
-
- result_tally() : msg("[OK]"), count(0)
- {
- time = std::chrono::system_clock::now();
- }
-
- result_tally(std::string&& err) : msg(std::move(err)), count(1)
- {
- time = std::chrono::system_clock::now();
- }
-
- void increment()
- {
- count++;
- time = std::chrono::system_clock::now();
- }
-
- bool compare(std::string& err)
- {
- if(msg == err)
- return true;
- else
- return false;
- }
- };
- std::vector<result_tally> vMineResults;
-
- //More result statistics
- std::array<size_t, 10> iTopDiff { { } }; //Initialize to zero
-
- std::chrono::system_clock::time_point tPoolConnTime;
- size_t iPoolHashes = 0;
- uint64_t iPoolDiff = 0;
-
- // Set it to 16 bit so that we can just let it grow
- // Maximum realistic growth rate - 5MB / month
- std::vector<uint16_t> iPoolCallTimes;
-
- //Those stats are reset if we disconnect
- inline void reset_stats()
- {
- iPoolCallTimes.clear();
- tPoolConnTime = std::chrono::system_clock::now();
- iPoolHashes = 0;
- iPoolDiff = 0;
- }
-
- double fHighestHps = 0.0;
-
- void log_socket_error(std::string&& sError);
- void log_result_ok(uint64_t iActualDiff);
-
- void sched_reconnect();
-
- void on_sock_ready(size_t pool_id);
- void on_sock_error(size_t pool_id, std::string&& sError);
- void on_pool_have_job(size_t pool_id, pool_job& oPoolJob);
- void on_miner_result(size_t pool_id, job_result& oResult);
- void on_reconnect(size_t pool_id);
- void on_switch_pool(size_t pool_id);
-
- inline size_t sec_to_ticks(size_t sec) { return sec * (1000 / iTickTime); }
-};
-
OpenPOWER on IntegriCloud