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)
};

View file

@ -460,7 +460,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
if (VARIANT > 0) {
if (VARIANT == xmrig::VARIANT_IBPC) {
if (VARIANT == xmrig::VARIANT_IPBC) {
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
}
else {
@ -568,7 +568,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
if (VARIANT > 0) {
if (VARIANT == xmrig::VARIANT_IBPC) {
if (VARIANT == xmrig::VARIANT_IPBC) {
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
}
else {
@ -602,7 +602,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
((uint64_t*)&l1[idx1 & MASK])[0] = al1;
if (VARIANT > 0) {
if (VARIANT == xmrig::VARIANT_IBPC) {
if (VARIANT == xmrig::VARIANT_IPBC) {
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1;
}
else {
@ -672,7 +672,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
if (VARIANT > 0) { \
_mm_store_si128(ptr, _mm_xor_si128(a, mc)); \
\
if (VARIANT == xmrig::VARIANT_IBPC) { \
if (VARIANT == xmrig::VARIANT_IPBC) { \
((uint64_t*)ptr)[1] ^= ((uint64_t*)ptr)[0]; \
} \
} else { \

View file

@ -62,7 +62,7 @@ bool xmrig::CpuThread::isSoftAES(AlgoVariant av)
xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant)
{
assert(variant == VARIANT_0 || variant == VARIANT_1 || variant == VARIANT_IBPC || variant == VARIANT_XTL);
assert(variant == VARIANT_0 || variant == VARIANT_1 || variant == VARIANT_IPBC || variant == VARIANT_XTL);
static const cn_hash_fun func_table[90] = {
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_0>,
@ -123,16 +123,16 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
# else

View file

@ -69,7 +69,7 @@ bool MultiWorker<N>::selfTest()
return false;
}
m_thread->fn(xmrig::VARIANT_IBPC)(test_input, 76, m_hash, m_ctx);
m_thread->fn(xmrig::VARIANT_IPBC)(test_input, 76, m_hash, m_ctx);
return memcmp(m_hash, test_output_ipbc_lite, sizeof m_hash) == 0;
}
# endif