Send supported algorithms to pool in login request.

This commit is contained in:
XMRig 2018-04-26 15:02:01 +07:00
parent bc2660f509
commit 41e8c4f887
9 changed files with 89 additions and 43 deletions

View file

@ -62,7 +62,7 @@ static AlgoData const algorithms[] = {
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
{ "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 },
{ "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 },
{ "cryptonight-lite/ipbc", "cn-lite/ipbc", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_IBPC },
{ "cryptonight-lite/ipbc", "cn-lite/ipbc", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_IPBC },
# endif
# ifndef XMRIG_NO_SUMO

View file

@ -26,6 +26,9 @@
#define __ALGORITHM_H__
#include <vector>
#include "common/xmrig.h"
@ -71,6 +74,9 @@ private:
};
typedef std::vector<xmrig::Algorithm> Algorithms;
} /* namespace xmrig */
#endif /* __ALGORITHM_H__ */

View file

@ -385,9 +385,10 @@ void Client::connect(sockaddr *addr)
void Client::login()
{
using namespace rapidjson;
m_results.clear();
rapidjson::Document doc;
Document doc;
doc.SetObject();
auto &allocator = doc.GetAllocator();
@ -396,19 +397,26 @@ void Client::login()
doc.AddMember("jsonrpc", "2.0", allocator);
doc.AddMember("method", "login", allocator);
rapidjson::Value params(rapidjson::kObjectType);
params.AddMember("login", rapidjson::StringRef(m_pool.user()), allocator);
params.AddMember("pass", rapidjson::StringRef(m_pool.password()), allocator);
params.AddMember("agent", rapidjson::StringRef(m_agent), allocator);
Value params(kObjectType);
params.AddMember("login", StringRef(m_pool.user()), allocator);
params.AddMember("pass", StringRef(m_pool.password()), allocator);
params.AddMember("agent", StringRef(m_agent), allocator);
if (m_pool.rigId()) {
params.AddMember("rigid", rapidjson::StringRef(m_pool.rigId()), allocator);
params.AddMember("rigid", StringRef(m_pool.rigId()), allocator);
}
Value algo(kArrayType);
for (const auto &a : m_pool.algorithms()) {
algo.PushBack(StringRef(a.shortName()), allocator);
}
params.AddMember("algo", algo, allocator);
doc.AddMember("params", params, allocator);
rapidjson::StringBuffer buffer(0, 512);
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
StringBuffer buffer(0, 512);
Writer<StringBuffer> writer(buffer);
doc.Accept(writer);
const size_t size = buffer.GetSize();

View file

@ -37,6 +37,9 @@
#endif
#define ADD_VARIANT(variant) m_algorithms.push_back(xmrig::Algorithm(m_algorithm.algo(), variant));
#ifdef _MSC_VER
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
@ -224,6 +227,33 @@ void Pool::adjust(xmrig::Algo algorithm)
m_keepAlive = false;
m_algorithm.setVariant(xmrig::VARIANT_1);
}
# ifndef XMRIG_PROXY_PROJECT
switch (m_algorithm.algo()) {
case xmrig::CRYPTONIGHT:
ADD_VARIANT(xmrig::VARIANT_AUTO);
ADD_VARIANT(xmrig::VARIANT_0);
ADD_VARIANT(xmrig::VARIANT_1);
ADD_VARIANT(xmrig::VARIANT_XTL);
break;
case xmrig::CRYPTONIGHT_LITE:
ADD_VARIANT(xmrig::VARIANT_AUTO);
ADD_VARIANT(xmrig::VARIANT_0);
ADD_VARIANT(xmrig::VARIANT_1);
ADD_VARIANT(xmrig::VARIANT_IPBC);
break;
case xmrig::CRYPTONIGHT_HEAVY:
ADD_VARIANT(xmrig::VARIANT_0);
break;
default:
break;
}
# else
m_algorithms.push_back(m_algorithm);
# endif
}

View file

@ -25,7 +25,7 @@
#define __POOL_H__
#include <stdint.h>
#include <vector>
#include "common/crypto/Algorithm.h"
@ -51,22 +51,23 @@ public:
bool nicehash = false
);
inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
inline const char *host() const { return m_host.data(); }
inline const char *password() const { return !m_password.isNull() ? m_password.data() : kDefaultPassword; }
inline const char *rigId() const { return m_rigId.data(); }
inline const char *url() const { return m_url.data(); }
inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
inline int keepAlive() const { return m_keepAlive; }
inline uint16_t port() const { return m_port; }
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
inline void setPassword(const char *password) { m_password = password; }
inline void setRigId(const char *rigId) { m_rigId = rigId; }
inline void setUser(const char *user) { m_user = user; }
inline xmrig::Algorithm &algorithm() { return m_algorithm; }
inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
inline const char *host() const { return m_host.data(); }
inline const char *password() const { return !m_password.isNull() ? m_password.data() : kDefaultPassword; }
inline const char *rigId() const { return m_rigId.data(); }
inline const char *url() const { return m_url.data(); }
inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
inline const xmrig::Algorithms &algorithms() const { return m_algorithms; }
inline int keepAlive() const { return m_keepAlive; }
inline uint16_t port() const { return m_port; }
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
inline void setPassword(const char *password) { m_password = password; }
inline void setRigId(const char *rigId) { m_rigId = rigId; }
inline void setUser(const char *user) { m_user = user; }
inline xmrig::Algorithm &algorithm() { return m_algorithm; }
inline bool operator!=(const Pool &other) const { return !isEqual(other); }
inline bool operator==(const Pool &other) const { return isEqual(other); }
@ -88,6 +89,7 @@ private:
int m_keepAlive;
uint16_t m_port;
xmrig::Algorithm m_algorithm;
xmrig::Algorithms m_algorithms;
xmrig::c_str m_host;
xmrig::c_str m_password;
xmrig::c_str m_rigId;

View file

@ -61,7 +61,7 @@ enum Variant {
VARIANT_AUTO = -1, // Autodetect
VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7
VARIANT_IBPC = 2, // CryptoNight Lite variant 1 with XOR (IPBC only)
VARIANT_IPBC = 2, // CryptoNight Lite variant 1 with XOR (IPBC only)
VARIANT_XTL = 3 // CryptoNight variant 1 (Stellite only)
};