Added "donate-over-proxy" option.

This commit is contained in:
XMRig 2019-03-19 00:16:30 +07:00
parent 55686c7d57
commit 0907d1eb0c
15 changed files with 229 additions and 141 deletions

View file

@ -114,8 +114,8 @@ static void print_threads(xmrig::Config *config)
config->threadsCount(),
config->algorithm().name(),
config->algoVariant(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[1;31m" : "",
config->donateLevel(),
config->isColors() && config->pools().donateLevel() == 0 ? "\x1B[1;31m" : "",
config->pools().donateLevel(),
buf);
}
else {
@ -124,8 +124,8 @@ static void print_threads(xmrig::Config *config)
"THREADS",
config->threadsCount(),
config->algorithm().name(),
config->isColors() && config->donateLevel() == 0 ? "\x1B[1;31m" : "",
config->donateLevel());
config->isColors() && config->pools().donateLevel() == 0 ? "\x1B[1;31m" : "",
config->pools().donateLevel());
}
# ifndef XMRIG_NO_ASM

View file

@ -254,7 +254,7 @@ void ApiRouter::getMiner(rapidjson::Document &doc) const
doc.AddMember("cpu", cpu, allocator);
doc.AddMember("algo", rapidjson::StringRef(m_controller->config()->algorithm().name()), allocator);
doc.AddMember("hugepages", Workers::hugePages() > 0, allocator);
doc.AddMember("donate_level", m_controller->config()->donateLevel(), allocator);
doc.AddMember("donate_level", m_controller->config()->pools().donateLevel(), allocator);
}

View file

@ -741,6 +741,11 @@ void xmrig::Client::parseExtensions(const rapidjson::Value &result)
else if (strcmp(name, "keepalive") == 0) {
setExtension(EXT_KEEPALIVE, true);
}
# ifdef XMRIG_FEATURE_TLS
else if (strcmp(name, "tls") == 0) {
setExtension(EXT_TLS, true);
}
# endif
}
}

View file

@ -68,6 +68,7 @@ public:
EXT_ALGO,
EXT_NICEHASH,
EXT_CONNECT,
EXT_TLS,
EXT_KEEPALIVE,
EXT_MAX
};

View file

@ -27,12 +27,15 @@
#include "base/net/stratum/strategies/FailoverStrategy.h"
#include "base/net/stratum/strategies/SinglePoolStrategy.h"
#include "common/log/Log.h"
#include "donate.h"
#include "rapidjson/document.h"
xmrig::Pools::Pools() :
m_donateLevel(kDefaultDonateLevel),
m_retries(5),
m_retryPause(5)
m_retryPause(5),
m_proxyDonate(PROXY_DONATE_AUTO)
{
# ifdef XMRIG_PROXY_PROJECT
m_retries = 2;
@ -191,6 +194,25 @@ void xmrig::Pools::print() const
}
void xmrig::Pools::setDonateLevel(int level)
{
if (level >= kMinimumDonateLevel && level <= 99) {
m_donateLevel = level;
}
}
void xmrig::Pools::setProxyDonate(int value)
{
switch (value) {
case PROXY_DONATE_NONE:
case PROXY_DONATE_AUTO:
case PROXY_DONATE_ALWAYS:
m_proxyDonate = static_cast<ProxyDonate>(value);
}
}
void xmrig::Pools::setRetries(int retries)
{
if (retries > 0 && retries <= 1000) {

View file

@ -42,12 +42,20 @@ class IStrategyListener;
class Pools
{
public:
enum ProxyDonate {
PROXY_DONATE_NONE,
PROXY_DONATE_AUTO,
PROXY_DONATE_ALWAYS
};
Pools();
inline bool setUserpass(const char *userpass) { return current().setUserpass(userpass); }
inline const std::vector<Pool> &data() const { return m_data; }
inline int donateLevel() const { return m_donateLevel; }
inline int retries() const { return m_retries; }
inline int retryPause() const { return m_retryPause; }
inline ProxyDonate proxyDonate() const { return m_proxyDonate; }
inline void setFingerprint(const char *fingerprint) { current().setFingerprint(fingerprint); }
inline void setKeepAlive(bool enable) { current().setKeepAlive(enable); }
inline void setKeepAlive(int keepAlive) { current().setKeepAlive(keepAlive); }
@ -70,14 +78,18 @@ public:
void adjust(const Algorithm &algorithm);
void load(const rapidjson::Value &pools);
void print() const;
void setDonateLevel(int level);
void setProxyDonate(int value);
void setRetries(int retries);
void setRetryPause(int retryPause);
private:
Pool &current();
int m_donateLevel;
int m_retries;
int m_retryPause;
ProxyDonate m_proxyDonate;
std::vector<Pool> m_data;
};

View file

@ -57,7 +57,6 @@
#include "base/io/Json.h"
#include "common/config/CommonConfig.h"
#include "common/log/Log.h"
#include "donate.h"
#include "rapidjson/document.h"
#include "rapidjson/filewritestream.h"
#include "rapidjson/prettywriter.h"
@ -75,7 +74,6 @@ xmrig::CommonConfig::CommonConfig() :
m_syslog(false),
m_watch(true),
m_apiPort(0),
m_donateLevel(kDefaultDonateLevel),
m_printTime(60),
m_state(NoneState)
{
@ -397,9 +395,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
break;
case DonateLevelKey: /* --donate-level */
if (arg >= kMinimumDonateLevel && arg <= 99) {
m_donateLevel = arg;
}
m_pools.setDonateLevel(arg);
break;
case ProxyDonateKey: /* --donate-over-proxy */
m_pools.setProxyDonate(arg);
break;
case ApiPort: /* --api-port */

View file

@ -53,7 +53,6 @@ public:
inline const char *userAgent() const { return m_userAgent.data(); }
inline const Pools &pools() const { return m_pools; }
inline int apiPort() const { return m_apiPort; }
inline int donateLevel() const { return m_donateLevel; }
inline int printTime() const { return m_printTime; }
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
@ -91,7 +90,6 @@ protected:
bool m_syslog;
bool m_watch;
int m_apiPort;
int m_donateLevel;
int m_printTime;
Pools m_pools;
State m_state;

View file

@ -69,6 +69,7 @@ public:
TlsKey = 1013,
FingerprintKey = 1014,
AutoSaveKey = 1016,
ProxyDonateKey = 1017,
// xmrig common
CPUPriorityKey = 1021,

View file

@ -16,6 +16,7 @@
"cpu-affinity": null,
"cpu-priority": null,
"donate-level": 5,
"donate-over-proxy": 1,
"huge-pages": true,
"hw-aes": null,
"log-file": null,

View file

@ -98,10 +98,11 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
}
doc.AddMember("cpu-priority", priority() != -1 ? Value(priority()) : Value(kNullType), allocator);
doc.AddMember("donate-level", donateLevel(), allocator);
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
doc.AddMember("huge-pages", isHugePages(), allocator);
doc.AddMember("hw-aes", m_aesMode == AES_AUTO ? Value(kNullType) : Value(m_aesMode == AES_HW), allocator);
doc.AddMember("log-file", logFile() ? Value(StringRef(logFile())).Move() : Value(kNullType).Move(), allocator);
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
doc.AddMember("max-cpu-usage", m_maxCpuUsage, allocator);
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
doc.AddMember("print-time", printTime(), allocator);

View file

@ -44,81 +44,83 @@ static char const short_options[] = "a:c:kBp:Px:r:R:s:t:T:o:u:O:v:l:S";
static struct option const options[] = {
{ "algo", 1, nullptr, xmrig::IConfig::AlgorithmKey },
{ "api-access-token", 1, nullptr, xmrig::IConfig::ApiAccessTokenKey },
{ "api-port", 1, nullptr, xmrig::IConfig::ApiPort },
{ "api-worker-id", 1, nullptr, xmrig::IConfig::ApiWorkerIdKey },
{ "api-id", 1, nullptr, xmrig::IConfig::ApiIdKey },
{ "api-ipv6", 0, nullptr, xmrig::IConfig::ApiIPv6Key },
{ "api-no-restricted", 0, nullptr, xmrig::IConfig::ApiRestrictedKey },
{ "av", 1, nullptr, xmrig::IConfig::AVKey },
{ "background", 0, nullptr, xmrig::IConfig::BackgroundKey },
{ "config", 1, nullptr, xmrig::IConfig::ConfigKey },
{ "cpu-affinity", 1, nullptr, xmrig::IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, xmrig::IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, xmrig::IConfig::DonateLevelKey },
{ "dry-run", 0, nullptr, xmrig::IConfig::DryRunKey },
{ "keepalive", 0, nullptr, xmrig::IConfig::KeepAliveKey },
{ "log-file", 1, nullptr, xmrig::IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey },
{ "nicehash", 0, nullptr, xmrig::IConfig::NicehashKey },
{ "no-color", 0, nullptr, xmrig::IConfig::ColorKey },
{ "no-watch", 0, nullptr, xmrig::IConfig::WatchKey },
{ "no-huge-pages", 0, nullptr, xmrig::IConfig::HugePagesKey },
{ "variant", 1, nullptr, xmrig::IConfig::VariantKey },
{ "pass", 1, nullptr, xmrig::IConfig::PasswordKey },
{ "print-time", 1, nullptr, xmrig::IConfig::PrintTimeKey },
{ "retries", 1, nullptr, xmrig::IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, xmrig::IConfig::RetryPauseKey },
{ "safe", 0, nullptr, xmrig::IConfig::SafeKey },
{ "syslog", 0, nullptr, xmrig::IConfig::SyslogKey },
{ "threads", 1, nullptr, xmrig::IConfig::ThreadsKey },
{ "url", 1, nullptr, xmrig::IConfig::UrlKey },
{ "user", 1, nullptr, xmrig::IConfig::UserKey },
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
{ "userpass", 1, nullptr, xmrig::IConfig::UserpassKey },
{ "rig-id", 1, nullptr, xmrig::IConfig::RigIdKey },
{ "tls", 0, nullptr, xmrig::IConfig::TlsKey },
{ "tls-fingerprint", 1, nullptr, xmrig::IConfig::FingerprintKey },
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
{ "api-access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
{ "api-port", 1, nullptr, IConfig::ApiPort },
{ "api-worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
{ "api-id", 1, nullptr, IConfig::ApiIdKey },
{ "api-ipv6", 0, nullptr, IConfig::ApiIPv6Key },
{ "api-no-restricted", 0, nullptr, IConfig::ApiRestrictedKey },
{ "av", 1, nullptr, IConfig::AVKey },
{ "background", 0, nullptr, IConfig::BackgroundKey },
{ "config", 1, nullptr, IConfig::ConfigKey },
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
{ "keepalive", 0, nullptr, IConfig::KeepAliveKey },
{ "log-file", 1, nullptr, IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
{ "nicehash", 0, nullptr, IConfig::NicehashKey },
{ "no-color", 0, nullptr, IConfig::ColorKey },
{ "no-watch", 0, nullptr, IConfig::WatchKey },
{ "no-huge-pages", 0, nullptr, IConfig::HugePagesKey },
{ "variant", 1, nullptr, IConfig::VariantKey },
{ "pass", 1, nullptr, IConfig::PasswordKey },
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
{ "retries", 1, nullptr, IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
{ "safe", 0, nullptr, IConfig::SafeKey },
{ "syslog", 0, nullptr, IConfig::SyslogKey },
{ "threads", 1, nullptr, IConfig::ThreadsKey },
{ "url", 1, nullptr, IConfig::UrlKey },
{ "user", 1, nullptr, IConfig::UserKey },
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
{ "userpass", 1, nullptr, IConfig::UserpassKey },
{ "rig-id", 1, nullptr, IConfig::RigIdKey },
{ "tls", 0, nullptr, IConfig::TlsKey },
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
{ "asm", 1, nullptr, IConfig::AssemblyKey },
{ nullptr, 0, nullptr, 0 }
};
static struct option const config_options[] = {
{ "algo", 1, nullptr, xmrig::IConfig::AlgorithmKey },
{ "av", 1, nullptr, xmrig::IConfig::AVKey },
{ "background", 0, nullptr, xmrig::IConfig::BackgroundKey },
{ "colors", 0, nullptr, xmrig::IConfig::ColorKey },
{ "cpu-affinity", 1, nullptr, xmrig::IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, xmrig::IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, xmrig::IConfig::DonateLevelKey },
{ "dry-run", 0, nullptr, xmrig::IConfig::DryRunKey },
{ "huge-pages", 0, nullptr, xmrig::IConfig::HugePagesKey },
{ "log-file", 1, nullptr, xmrig::IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey },
{ "print-time", 1, nullptr, xmrig::IConfig::PrintTimeKey },
{ "retries", 1, nullptr, xmrig::IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, xmrig::IConfig::RetryPauseKey },
{ "safe", 0, nullptr, xmrig::IConfig::SafeKey },
{ "syslog", 0, nullptr, xmrig::IConfig::SyslogKey },
{ "threads", 1, nullptr, xmrig::IConfig::ThreadsKey },
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
{ "watch", 0, nullptr, xmrig::IConfig::WatchKey },
{ "hw-aes", 0, nullptr, xmrig::IConfig::HardwareAESKey },
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
{ "autosave", 0, nullptr, xmrig::IConfig::AutoSaveKey },
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
{ "av", 1, nullptr, IConfig::AVKey },
{ "background", 0, nullptr, IConfig::BackgroundKey },
{ "colors", 0, nullptr, IConfig::ColorKey },
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
{ "huge-pages", 0, nullptr, IConfig::HugePagesKey },
{ "log-file", 1, nullptr, IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
{ "retries", 1, nullptr, IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
{ "safe", 0, nullptr, IConfig::SafeKey },
{ "syslog", 0, nullptr, IConfig::SyslogKey },
{ "threads", 1, nullptr, IConfig::ThreadsKey },
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
{ "watch", 0, nullptr, IConfig::WatchKey },
{ "hw-aes", 0, nullptr, IConfig::HardwareAESKey },
{ "asm", 1, nullptr, IConfig::AssemblyKey },
{ "autosave", 0, nullptr, IConfig::AutoSaveKey },
{ nullptr, 0, nullptr, 0 }
};
static struct option const api_options[] = {
{ "port", 1, nullptr, xmrig::IConfig::ApiPort },
{ "access-token", 1, nullptr, xmrig::IConfig::ApiAccessTokenKey },
{ "worker-id", 1, nullptr, xmrig::IConfig::ApiWorkerIdKey },
{ "ipv6", 0, nullptr, xmrig::IConfig::ApiIPv6Key },
{ "restricted", 0, nullptr, xmrig::IConfig::ApiRestrictedKey },
{ "id", 1, nullptr, xmrig::IConfig::ApiIdKey },
{ "port", 1, nullptr, IConfig::ApiPort },
{ "access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
{ "worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
{ "ipv6", 0, nullptr, IConfig::ApiIPv6Key },
{ "restricted", 0, nullptr, IConfig::ApiRestrictedKey },
{ "id", 1, nullptr, IConfig::ApiIdKey },
{ nullptr, 0, nullptr, 0 }
};

View file

@ -54,8 +54,8 @@ xmrig::Network::Network(Controller *controller) :
const Pools &pools = controller->config()->pools();
m_strategy = pools.createStrategy(this);
if (controller->config()->donateLevel() > 0) {
m_donate = new DonateStrategy(controller->config()->donateLevel(), pools.data().front().user(), controller->config()->algorithm().algo(), this);
if (pools.donateLevel() > 0) {
m_donate = new DonateStrategy(controller, this);
}
m_timer = new Timer(this, kTickInterval, kTickInterval);

View file

@ -23,6 +23,9 @@
*/
#include <assert.h>
#include "base/net/stratum/Client.h"
#include "base/net/stratum/Job.h"
#include "base/net/stratum/strategies/FailoverStrategy.h"
@ -32,6 +35,9 @@
#include "common/crypto/keccak.h"
#include "common/Platform.h"
#include "common/xmrig.h"
#include "core/Config.h"
#include "core/Controller.h"
#include "net/Network.h"
#include "net/strategies/DonateStrategy.h"
@ -40,32 +46,39 @@ namespace xmrig {
static inline double randomf(double min, double max) { return (max - min) * (((static_cast<double>(rand())) / static_cast<double>(RAND_MAX))) + min; }
static inline uint64_t random(uint64_t base, double min, double max) { return static_cast<uint64_t>(base * randomf(min, max)); }
static const char *kDonateHost = "donate.v2.xmrig.com";
#ifdef XMRIG_FEATURE_TLS
static const char *kDonateHostTls = "donate.ssl.xmrig.com";
#endif
} /* namespace xmrig */
xmrig::DonateStrategy::DonateStrategy(int level, const char *user, Algo algo, IStrategyListener *listener) :
m_active(false),
m_donateTime(static_cast<uint64_t>(level) * 60 * 1000),
m_idleTime((100 - static_cast<uint64_t>(level)) * 60 * 1000),
xmrig::DonateStrategy::DonateStrategy(Controller *controller, IStrategyListener *listener) :
m_proxy(nullptr),
m_donateTime(static_cast<uint64_t>(controller->config()->pools().donateLevel()) * 60 * 1000),
m_idleTime((100 - static_cast<uint64_t>(controller->config()->pools().donateLevel())) * 60 * 1000),
m_controller(controller),
m_strategy(nullptr),
m_listener(listener),
m_state(STATE_NEW),
m_now(0),
m_stop(0)
{
uint8_t hash[200];
char userId[65] = { 0 };
keccak(reinterpret_cast<const uint8_t *>(user), strlen(user), hash);
const String &user = controller->config()->pools().data().front().user();
keccak(reinterpret_cast<const uint8_t *>(user.data()), user.size(), hash);
Buffer::toHex(hash, 32, userId);
# ifdef XMRIG_FEATURE_TLS
m_pools.push_back(Pool("donate.ssl.xmrig.com", 443, userId, nullptr, false, true, true));
m_pools.push_back(Pool(kDonateHostTls, 443, userId, nullptr, false, true, true));
# endif
m_pools.push_back(Pool("donate.v2.xmrig.com", 3333, userId, nullptr, false, true));
m_pools.push_back(Pool(kDonateHost, 3333, userId, nullptr, false, true));
for (Pool &pool : m_pools) {
pool.adjust(Algorithm(algo, VARIANT_AUTO));
pool.adjust(Algorithm(controller->config()->algorithm().algo(), VARIANT_AUTO));
}
if (m_pools.size() > 1) {
@ -77,7 +90,7 @@ xmrig::DonateStrategy::DonateStrategy(int level, const char *user, Algo algo, IS
m_timer = new Timer(this);
idle(random(m_idleTime, 0.5, 1.5));
setState(STATE_IDLE);
}
@ -119,20 +132,19 @@ void xmrig::DonateStrategy::tick(uint64_t now)
m_strategy->tick(now);
if (m_stop && now > m_stop) {
m_strategy->stop();
m_stop = 0;
if (state() == STATE_WAIT && now > m_stop) {
setState(STATE_IDLE);
}
}
void xmrig::DonateStrategy::onActive(IStrategy *strategy, Client *client)
{
if (!isActive()) {
m_timer->start(m_donateTime, 0);
if (isActive()) {
return;
}
m_active = true;
setState(STATE_ACTIVE);
m_listener->onActive(this, client);
}
@ -158,30 +170,53 @@ void xmrig::DonateStrategy::onResultAccepted(IStrategy *strategy, Client *client
void xmrig::DonateStrategy::onTimer(const Timer *)
{
if (!isActive()) {
return connect();
}
suspend();
setState(isActive() ? STATE_WAIT : STATE_CONNECT);
}
void xmrig::DonateStrategy::idle(uint64_t timeout)
void xmrig::DonateStrategy::idle(double min, double max)
{
m_timer->start(timeout, 0);
m_timer->start(random(m_idleTime, min, max), 0);
}
void xmrig::DonateStrategy::suspend()
void xmrig::DonateStrategy::setState(State state)
{
# if defined(XMRIG_AMD_PROJECT) || defined(XMRIG_NVIDIA_PROJECT)
m_stop = m_now + 5000;
# else
m_stop = m_now + 500;
# endif
constexpr const uint64_t waitTime = 3000;
m_active = false;
assert(m_state != state && state != STATE_NEW);
if (m_state == state) {
return;
}
const State prev = m_state;
m_state = state;
switch (state) {
case STATE_NEW:
break;
case STATE_IDLE:
if (prev == STATE_NEW) {
idle(0.5, 1.5);
}
else {
m_strategy->stop();
idle(0.8, 1.2);
}
break;
case STATE_CONNECT:
connect();
break;
case STATE_ACTIVE:
m_timer->start(m_donateTime, 0);
break;
case STATE_WAIT:
m_stop = m_now + waitTime;
m_listener->onPause(this);
idle(random(m_idleTime, 0.8, 1.2));
break;
}
}

View file

@ -26,7 +26,6 @@
#define XMRIG_DONATESTRATEGY_H
#include <uv.h>
#include <vector>
@ -41,17 +40,18 @@ namespace xmrig {
class Client;
class Controller;
class IStrategyListener;
class DonateStrategy : public IStrategy, public IStrategyListener, public ITimerListener
{
public:
DonateStrategy(int level, const char *user, Algo algo, IStrategyListener *listener);
DonateStrategy(Controller *controller, IStrategyListener *listener);
~DonateStrategy() override;
public:
inline bool isActive() const override { return m_active; }
inline bool isActive() const override { return state() == STATE_ACTIVE; }
inline void resume() override {}
int64_t submit(const JobResult &result) override;
@ -68,20 +68,30 @@ protected:
void onTimer(const Timer *timer) override;
private:
void idle(uint64_t timeout);
void suspend();
enum State {
STATE_NEW,
STATE_IDLE,
STATE_CONNECT,
STATE_ACTIVE,
STATE_WAIT
};
static void onTimer(uv_timer_t *handle);
inline State state() const { return m_state; }
bool m_active;
void idle(double min, double max);
void setState(State state);
Client *m_proxy;
const uint64_t m_donateTime;
const uint64_t m_idleTime;
Controller *m_controller;
IStrategy *m_strategy;
IStrategyListener *m_listener;
State m_state;
std::vector<Pool> m_pools;
Timer *m_timer;
uint64_t m_now;
uint64_t m_stop;
Timer *m_timer;
};