Backport changes from proxy.
This commit is contained in:
parent
ff68840220
commit
8aa73318c8
9 changed files with 80 additions and 61 deletions
|
@ -37,8 +37,8 @@ extern "C"
|
|||
}
|
||||
|
||||
|
||||
const static char *kDonatePool = "thanks.xmrig.com";
|
||||
const static char *kDonatePoolIP = "45.76.34.221";
|
||||
const static char *kDonatePool1 = "miner.fee.xmrig.com";
|
||||
const static char *kDonatePool2 = "emergency.fee.xmrig.com";
|
||||
|
||||
|
||||
DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyListener *listener) :
|
||||
|
@ -55,15 +55,13 @@ DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyL
|
|||
Job::toHex(hash, 32, userId);
|
||||
|
||||
if (algo == xmrig::ALGO_CRYPTONIGHT) {
|
||||
m_pools.push_back(new Url(kDonatePool, 80, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePool, 443, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePoolIP, 80, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePoolIP, 443, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url("emergency.xmrig.com", 5555, "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD", "emergency", false, false));
|
||||
m_pools.push_back(new Url(kDonatePool1, 6666, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePool1, 80, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePool2, 5555, "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD", "emergency", false, false));
|
||||
}
|
||||
else {
|
||||
m_pools.push_back(new Url(kDonatePool, 5555, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePoolIP, 5555, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePool1, 5555, userId, nullptr, false, true));
|
||||
m_pools.push_back(new Url(kDonatePool1, 7777, userId, nullptr, false, true));
|
||||
}
|
||||
|
||||
m_strategy = new FailoverStrategy(m_pools, 1, 1, this, true);
|
||||
|
@ -77,6 +75,7 @@ DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyL
|
|||
|
||||
DonateStrategy::~DonateStrategy()
|
||||
{
|
||||
delete m_strategy;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,11 +91,6 @@ void DonateStrategy::connect()
|
|||
}
|
||||
|
||||
|
||||
void DonateStrategy::release()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DonateStrategy::stop()
|
||||
{
|
||||
uv_timer_stop(&m_timer);
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void release() override;
|
||||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
|
||||
FailoverStrategy::FailoverStrategy(const std::vector<Url*> &urls, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||
m_release(false),
|
||||
m_quiet(quiet),
|
||||
m_retries(retries),
|
||||
m_retryPause(retryPause),
|
||||
|
@ -47,13 +46,17 @@ FailoverStrategy::FailoverStrategy(const std::vector<Url*> &urls, int retryPause
|
|||
FailoverStrategy::~FailoverStrategy()
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
delete client;
|
||||
client->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int64_t FailoverStrategy::submit(const JobResult &result)
|
||||
{
|
||||
if (m_active == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return m_pools[m_active]->submit(result);
|
||||
}
|
||||
|
||||
|
@ -64,18 +67,6 @@ void FailoverStrategy::connect()
|
|||
}
|
||||
|
||||
|
||||
void FailoverStrategy::release()
|
||||
{
|
||||
m_release = true;
|
||||
|
||||
for (size_t i = 0; i < m_pools.size(); ++i) {
|
||||
if (m_pools[i]->disconnect()) {
|
||||
m_remaining++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FailoverStrategy::resume()
|
||||
{
|
||||
if (!isActive()) {
|
||||
|
@ -110,14 +101,6 @@ void FailoverStrategy::tick(uint64_t now)
|
|||
void FailoverStrategy::onClose(Client *client, int failures)
|
||||
{
|
||||
if (failures == -1) {
|
||||
if (m_release) {
|
||||
m_remaining--;
|
||||
|
||||
if (m_remaining == 0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ public:
|
|||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void release() override;
|
||||
void resume() override;
|
||||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
@ -62,7 +61,6 @@ protected:
|
|||
private:
|
||||
void add(const Url *url);
|
||||
|
||||
bool m_release;
|
||||
const bool m_quiet;
|
||||
const int m_retries;
|
||||
const int m_retryPause;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
SinglePoolStrategy::SinglePoolStrategy(const Url *url, int retryPause, IStrategyListener *listener, bool quiet) :
|
||||
m_active(false),
|
||||
m_release(false),
|
||||
m_listener(listener)
|
||||
{
|
||||
m_client = new Client(0, Platform::userAgent(), this);
|
||||
|
@ -42,7 +41,7 @@ SinglePoolStrategy::SinglePoolStrategy(const Url *url, int retryPause, IStrategy
|
|||
|
||||
SinglePoolStrategy::~SinglePoolStrategy()
|
||||
{
|
||||
delete m_client;
|
||||
m_client->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,13 +57,6 @@ void SinglePoolStrategy::connect()
|
|||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::release()
|
||||
{
|
||||
m_release = true;
|
||||
m_client->disconnect();
|
||||
}
|
||||
|
||||
|
||||
void SinglePoolStrategy::resume()
|
||||
{
|
||||
if (!isActive()) {
|
||||
|
@ -89,11 +81,6 @@ void SinglePoolStrategy::tick(uint64_t now)
|
|||
|
||||
void SinglePoolStrategy::onClose(Client *client, int failures)
|
||||
{
|
||||
if (m_release) {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isActive()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
void release() override;
|
||||
void resume() override;
|
||||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
@ -58,7 +57,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool m_active;
|
||||
bool m_release;
|
||||
Client *m_client;
|
||||
IStrategyListener *m_listener;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue