Prepare for per pool and per job algorithms.

This commit is contained in:
XMRig 2018-04-21 19:55:51 +07:00
parent 274992e50d
commit 45e8a0525c
14 changed files with 116 additions and 84 deletions

View file

@ -166,12 +166,9 @@ bool Network::isColors() const
void Network::setJob(Client *client, const Job &job, bool donate)
{
if (isColors()) {
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m diff \x1B[01;37m%d", client->host(), client->port(), job.diff());
}
else {
LOG_INFO("new job from %s:%d diff %d", client->host(), client->port(), job.diff());
}
LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s/%d")
: "new job from %s:%d diff %d algo %s/%d",
client->host(), client->port(), job.diff(), Pool::algoName(job.algorithm(), true), static_cast<int>(job.variant()));
m_state.diff = job.diff();
Workers::setJob(job, donate);

View file

@ -26,6 +26,7 @@
#include "common/net/Client.h"
#include "common/net/Job.h"
#include "common/net/strategies/FailoverStrategy.h"
#include "common/net/strategies/SinglePoolStrategy.h"
#include "common/Platform.h"
#include "common/xmrig.h"
#include "interfaces/IStrategyListener.h"
@ -41,7 +42,7 @@ static inline float randomf(float min, float max) {
}
DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyListener *listener) :
DonateStrategy::DonateStrategy(int level, const char *user, xmrig::Algo algo, IStrategyListener *listener) :
m_active(false),
m_donateTime(level * 60 * 1000),
m_idleTime((100 - level) * 60 * 1000),
@ -61,14 +62,24 @@ DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyL
}
else if (algo == xmrig::CRYPTONIGHT_HEAVY) {
m_pools.push_back(Pool(kDonatePool1, 8888, userId, nullptr, false, true));
m_pools.push_back(Pool(kDonatePool1, 8889, userId, nullptr, false, true));
}
else if (algo == xmrig::CRYPTONIGHT_IPBC) {
m_pools.push_back(Pool(kDonatePool1, 13333, userId, nullptr, false, true));
}
else {
m_pools.push_back(Pool(kDonatePool1, 5555, userId, nullptr, false, true));
m_pools.push_back(Pool(kDonatePool1, 7777, userId, nullptr, false, true));
}
m_strategy = new FailoverStrategy(m_pools, 1, 1, this, true);
for (Pool &pool : m_pools) {
pool.setAlgo(algo);
}
if (m_pools.size() > 1) {
m_strategy = new FailoverStrategy(m_pools, 1, 2, this, true);
}
else {
m_strategy = new SinglePoolStrategy(m_pools.front(), 1, this, true);
}
m_timer.data = this;
uv_timer_init(uv_default_loop(), &m_timer);

View file

@ -43,7 +43,7 @@ class Url;
class DonateStrategy : public IStrategy, public IStrategyListener
{
public:
DonateStrategy(int level, const char *user, int algo, IStrategyListener *listener);
DonateStrategy(int level, const char *user, xmrig::Algo algo, IStrategyListener *listener);
~DonateStrategy();
public: