mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-09 12:29:24 +00:00
Initial multiple pools support [2/2].
This commit is contained in:
parent
952017ae7a
commit
c0dcfc2a97
7 changed files with 35 additions and 54 deletions
|
@ -105,7 +105,7 @@ int App::exec()
|
|||
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash());
|
||||
Summary::print();
|
||||
|
||||
Workers::start(m_options->affinity(), m_options->nicehash());
|
||||
Workers::start(m_options->affinity(), false);
|
||||
|
||||
m_network->connect();
|
||||
|
||||
|
|
|
@ -143,13 +143,10 @@ Options::Options(int argc, char **argv) :
|
|||
m_background(false),
|
||||
m_colors(true),
|
||||
m_doubleHash(false),
|
||||
m_keepAlive(false),
|
||||
m_nicehash(false),
|
||||
m_ready(false),
|
||||
m_safe(false),
|
||||
m_syslog(false),
|
||||
m_logFile(nullptr),
|
||||
m_pass(nullptr),
|
||||
m_algo(0),
|
||||
m_algoVariant(0),
|
||||
m_donateLevel(kDonateLevel),
|
||||
|
@ -185,18 +182,6 @@ Options::Options(int argc, char **argv) :
|
|||
return;
|
||||
}
|
||||
|
||||
// if (!m_nicehash && m_url->isNicehash()) {
|
||||
// m_nicehash = true;
|
||||
// }
|
||||
|
||||
// if (!m_user) {
|
||||
// m_user = strdup("x");
|
||||
// }
|
||||
|
||||
if (!m_pass) {
|
||||
m_pass = strdup("x");
|
||||
}
|
||||
|
||||
m_algoVariant = getAlgoVariant();
|
||||
if (m_algoVariant == AV2_AESNI_DOUBLE || m_algoVariant == AV4_SOFT_AES_DOUBLE) {
|
||||
m_doubleHash = true;
|
||||
|
@ -218,7 +203,6 @@ Options::Options(int argc, char **argv) :
|
|||
|
||||
Options::~Options()
|
||||
{
|
||||
free(m_pass);
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,13 +220,14 @@ bool Options::parseArg(int key, char *arg)
|
|||
break;
|
||||
|
||||
case 'O': /* --userpass */
|
||||
if (!setUserpass(arg)) {
|
||||
if (!m_pools.back()->setUserpass(arg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'o': /* --url */
|
||||
if (m_pools[0]->isValid()) {
|
||||
if (m_pools.size() > 1 || m_pools[0]->isValid()) {
|
||||
Url *url = new Url(arg);
|
||||
if (url->isValid()) {
|
||||
m_pools.push_back(url);
|
||||
|
@ -254,6 +239,11 @@ bool Options::parseArg(int key, char *arg)
|
|||
else {
|
||||
m_pools[0]->parse(arg);
|
||||
}
|
||||
|
||||
if (!m_pools.back()->isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'u': /* --user */
|
||||
|
@ -315,7 +305,7 @@ bool Options::parseArg(int key, char *arg)
|
|||
break;
|
||||
|
||||
case 'k': /* --keepalive */
|
||||
m_keepAlive = true;
|
||||
m_pools.back()->setKeepAlive(true);
|
||||
break;
|
||||
|
||||
case 'V': /* --version */
|
||||
|
@ -371,7 +361,7 @@ bool Options::parseArg(int key, char *arg)
|
|||
break;
|
||||
|
||||
case 1006: /* --nicehash */
|
||||
m_nicehash = true;
|
||||
m_pools.back()->setNicehash(true);
|
||||
break;
|
||||
|
||||
case 1007: /* --print-time */
|
||||
|
@ -474,25 +464,6 @@ bool Options::setAlgo(const char *algo)
|
|||
}
|
||||
|
||||
|
||||
bool Options::setUserpass(const char *userpass)
|
||||
{
|
||||
// const char *p = strchr(userpass, ':');
|
||||
// if (!p) {
|
||||
// showUsage(1);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
//// free(m_user);
|
||||
// free(m_pass);
|
||||
|
||||
//// m_user = static_cast<char*>(calloc(p - userpass + 1, 1));
|
||||
// strncpy(m_user, userpass, p - userpass);
|
||||
// m_pass = strdup(p + 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int Options::getAlgoVariant() const
|
||||
{
|
||||
# ifndef XMRIG_NO_AEON
|
||||
|
|
|
@ -56,11 +56,8 @@ public:
|
|||
inline bool colors() const { return m_colors; }
|
||||
inline bool doubleHash() const { return m_doubleHash; }
|
||||
inline bool isReady() const { return m_ready; }
|
||||
inline bool keepAlive() const { return m_keepAlive; }
|
||||
inline bool nicehash() const { return m_nicehash; }
|
||||
inline bool syslog() const { return m_syslog; }
|
||||
inline const char *logFile() const { return m_logFile; }
|
||||
inline const char *pass() const { return m_pass; }
|
||||
inline const std::vector<Url*> &pools() const { return m_pools; }
|
||||
inline int algo() const { return m_algo; }
|
||||
inline int algoVariant() const { return m_algoVariant; }
|
||||
|
@ -85,7 +82,6 @@ private:
|
|||
void showVersion(void);
|
||||
|
||||
bool setAlgo(const char *algo);
|
||||
bool setUserpass(const char *userpass);
|
||||
|
||||
int getAlgoVariant() const;
|
||||
# ifndef XMRIG_NO_AEON
|
||||
|
@ -95,14 +91,10 @@ private:
|
|||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_doubleHash;
|
||||
bool m_keepAlive;
|
||||
bool m_nicehash;
|
||||
bool m_ready;
|
||||
bool m_safe;
|
||||
bool m_syslog;
|
||||
char *m_logFile;
|
||||
char *m_pass;
|
||||
// char *m_user;
|
||||
int m_algo;
|
||||
int m_algoVariant;
|
||||
int m_donateLevel;
|
||||
|
|
|
@ -100,12 +100,12 @@ static void print_threads()
|
|||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, donate=%d%%%s%s" : " * THREADS: %d, %s, av=%d, donate=%d%%%s%s",
|
||||
Log::i()->text(Options::i()->colors() ? "\x1B[01;32m * \x1B[01;37mTHREADS: \x1B[01;36m%d\x1B[01;37m, %s, av=%d, donate=%d%%%s" : " * THREADS: %d, %s, av=%d, donate=%d%%%s",
|
||||
Options::i()->threads(),
|
||||
Options::i()->algoName(),
|
||||
Options::i()->algoVariant(),
|
||||
Options::i()->donateLevel(),
|
||||
Options::i()->nicehash() ? ", nicehash" : "", buf);
|
||||
buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ Network::Network(const Options *options) :
|
|||
m_agent = userAgent();
|
||||
|
||||
addPool(std::make_unique<Url>().get());
|
||||
// addPool(m_options->url());
|
||||
addPool(m_options->pools().front());
|
||||
// addPool(m_options->backupUrl());
|
||||
|
||||
m_timer.data = this;
|
||||
|
@ -120,7 +120,7 @@ void Network::onJobResult(const JobResult &result)
|
|||
|
||||
void Network::onLoginCredentialsRequired(Client *client)
|
||||
{
|
||||
// client->login(m_options->user(), m_options->pass(), m_agent);
|
||||
client->login(m_options->pools().front()->password(), m_options->pools().front()->password(), m_agent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ void Network::addPool(const Url *url)
|
|||
Client *client = new Client(m_pools.size(), this);
|
||||
client->setUrl(url);
|
||||
client->setRetryPause(m_options->retryPause() * 1000);
|
||||
client->setKeepAlive(m_options->keepAlive());
|
||||
// client->setKeepAlive(m_options->keepAlive());
|
||||
|
||||
m_pools.push_back(client);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,24 @@ bool Url::parse(const char *url)
|
|||
}
|
||||
|
||||
|
||||
bool Url::setUserpass(const char *userpass)
|
||||
{
|
||||
const char *p = strchr(userpass, ':');
|
||||
if (!p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
free(m_user);
|
||||
free(m_password);
|
||||
|
||||
m_user = static_cast<char*>(calloc(p - userpass + 1, 1));
|
||||
strncpy(m_user, userpass, p - userpass);
|
||||
m_password = strdup(p + 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Url::setPassword(const char *password, bool force)
|
||||
{
|
||||
if (m_password != nullptr && !force) {
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
|
||||
bool isNicehash() const;
|
||||
bool parse(const char *url);
|
||||
bool setUserpass(const char *userpass);
|
||||
void setPassword(const char *password, bool force = true);
|
||||
void setUser(const char *user, bool force = true);
|
||||
|
||||
private:
|
||||
bool m_keepAlive;
|
||||
bool m_nicehash;
|
||||
|
|
Loading…
Reference in a new issue