mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-11 13:24:40 +00:00
Send supported algorithms to pool in login request.
This commit is contained in:
parent
bc2660f509
commit
41e8c4f887
9 changed files with 89 additions and 43 deletions
|
@ -62,7 +62,7 @@ static AlgoData const algorithms[] = {
|
||||||
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
{ "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO },
|
||||||
{ "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 },
|
{ "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/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
|
# endif
|
||||||
|
|
||||||
# ifndef XMRIG_NO_SUMO
|
# ifndef XMRIG_NO_SUMO
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#define __ALGORITHM_H__
|
#define __ALGORITHM_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "common/xmrig.h"
|
#include "common/xmrig.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +74,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::vector<xmrig::Algorithm> Algorithms;
|
||||||
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} /* namespace xmrig */
|
||||||
|
|
||||||
#endif /* __ALGORITHM_H__ */
|
#endif /* __ALGORITHM_H__ */
|
||||||
|
|
|
@ -385,9 +385,10 @@ void Client::connect(sockaddr *addr)
|
||||||
|
|
||||||
void Client::login()
|
void Client::login()
|
||||||
{
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
m_results.clear();
|
m_results.clear();
|
||||||
|
|
||||||
rapidjson::Document doc;
|
Document doc;
|
||||||
doc.SetObject();
|
doc.SetObject();
|
||||||
|
|
||||||
auto &allocator = doc.GetAllocator();
|
auto &allocator = doc.GetAllocator();
|
||||||
|
@ -396,19 +397,26 @@ void Client::login()
|
||||||
doc.AddMember("jsonrpc", "2.0", allocator);
|
doc.AddMember("jsonrpc", "2.0", allocator);
|
||||||
doc.AddMember("method", "login", allocator);
|
doc.AddMember("method", "login", allocator);
|
||||||
|
|
||||||
rapidjson::Value params(rapidjson::kObjectType);
|
Value params(kObjectType);
|
||||||
params.AddMember("login", rapidjson::StringRef(m_pool.user()), allocator);
|
params.AddMember("login", StringRef(m_pool.user()), allocator);
|
||||||
params.AddMember("pass", rapidjson::StringRef(m_pool.password()), allocator);
|
params.AddMember("pass", StringRef(m_pool.password()), allocator);
|
||||||
params.AddMember("agent", rapidjson::StringRef(m_agent), allocator);
|
params.AddMember("agent", StringRef(m_agent), allocator);
|
||||||
|
|
||||||
if (m_pool.rigId()) {
|
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);
|
doc.AddMember("params", params, allocator);
|
||||||
|
|
||||||
rapidjson::StringBuffer buffer(0, 512);
|
StringBuffer buffer(0, 512);
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
Writer<StringBuffer> writer(buffer);
|
||||||
doc.Accept(writer);
|
doc.Accept(writer);
|
||||||
|
|
||||||
const size_t size = buffer.GetSize();
|
const size_t size = buffer.GetSize();
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ADD_VARIANT(variant) m_algorithms.push_back(xmrig::Algorithm(m_algorithm.algo(), variant));
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define strncasecmp _strnicmp
|
# define strncasecmp _strnicmp
|
||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
|
@ -224,6 +227,33 @@ void Pool::adjust(xmrig::Algo algorithm)
|
||||||
m_keepAlive = false;
|
m_keepAlive = false;
|
||||||
m_algorithm.setVariant(xmrig::VARIANT_1);
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define __POOL_H__
|
#define __POOL_H__
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "common/crypto/Algorithm.h"
|
#include "common/crypto/Algorithm.h"
|
||||||
|
@ -51,22 +51,23 @@ public:
|
||||||
bool nicehash = false
|
bool nicehash = false
|
||||||
);
|
);
|
||||||
|
|
||||||
inline bool isNicehash() const { return m_nicehash; }
|
inline bool isNicehash() const { return m_nicehash; }
|
||||||
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
|
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
|
||||||
inline const char *host() const { return m_host.data(); }
|
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 *password() const { return !m_password.isNull() ? m_password.data() : kDefaultPassword; }
|
||||||
inline const char *rigId() const { return m_rigId.data(); }
|
inline const char *rigId() const { return m_rigId.data(); }
|
||||||
inline const char *url() const { return m_url.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 char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
|
||||||
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
|
inline const xmrig::Algorithm &algorithm() const { return m_algorithm; }
|
||||||
inline int keepAlive() const { return m_keepAlive; }
|
inline const xmrig::Algorithms &algorithms() const { return m_algorithms; }
|
||||||
inline uint16_t port() const { return m_port; }
|
inline int keepAlive() const { return m_keepAlive; }
|
||||||
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
|
inline uint16_t port() const { return m_port; }
|
||||||
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
|
||||||
inline void setPassword(const char *password) { m_password = password; }
|
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
|
||||||
inline void setRigId(const char *rigId) { m_rigId = rigId; }
|
inline void setPassword(const char *password) { m_password = password; }
|
||||||
inline void setUser(const char *user) { m_user = user; }
|
inline void setRigId(const char *rigId) { m_rigId = rigId; }
|
||||||
inline xmrig::Algorithm &algorithm() { return m_algorithm; }
|
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); }
|
||||||
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;
|
int m_keepAlive;
|
||||||
uint16_t m_port;
|
uint16_t m_port;
|
||||||
xmrig::Algorithm m_algorithm;
|
xmrig::Algorithm m_algorithm;
|
||||||
|
xmrig::Algorithms m_algorithms;
|
||||||
xmrig::c_str m_host;
|
xmrig::c_str m_host;
|
||||||
xmrig::c_str m_password;
|
xmrig::c_str m_password;
|
||||||
xmrig::c_str m_rigId;
|
xmrig::c_str m_rigId;
|
||||||
|
|
|
@ -61,7 +61,7 @@ enum Variant {
|
||||||
VARIANT_AUTO = -1, // Autodetect
|
VARIANT_AUTO = -1, // Autodetect
|
||||||
VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
|
VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy
|
||||||
VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7
|
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)
|
VARIANT_XTL = 3 // CryptoNight variant 1 (Stellite only)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
||||||
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||||
|
|
||||||
if (VARIANT > 0) {
|
if (VARIANT > 0) {
|
||||||
if (VARIANT == xmrig::VARIANT_IBPC) {
|
if (VARIANT == xmrig::VARIANT_IPBC) {
|
||||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||||
}
|
}
|
||||||
else {
|
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;
|
((uint64_t*)&l0[idx0 & MASK])[0] = al0;
|
||||||
|
|
||||||
if (VARIANT > 0) {
|
if (VARIANT > 0) {
|
||||||
if (VARIANT == xmrig::VARIANT_IBPC) {
|
if (VARIANT == xmrig::VARIANT_IPBC) {
|
||||||
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0;
|
||||||
}
|
}
|
||||||
else {
|
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;
|
((uint64_t*)&l1[idx1 & MASK])[0] = al1;
|
||||||
|
|
||||||
if (VARIANT > 0) {
|
if (VARIANT > 0) {
|
||||||
if (VARIANT == xmrig::VARIANT_IBPC) {
|
if (VARIANT == xmrig::VARIANT_IPBC) {
|
||||||
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1;
|
((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -672,7 +672,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si
|
||||||
if (VARIANT > 0) { \
|
if (VARIANT > 0) { \
|
||||||
_mm_store_si128(ptr, _mm_xor_si128(a, mc)); \
|
_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]; \
|
((uint64_t*)ptr)[1] ^= ((uint64_t*)ptr)[0]; \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool xmrig::CpuThread::isSoftAES(AlgoVariant av)
|
||||||
|
|
||||||
xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant av, Variant variant)
|
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] = {
|
static const cn_hash_fun func_table[90] = {
|
||||||
cryptonight_single_hash<CRYPTONIGHT, false, VARIANT_0>,
|
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_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
|
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_1>,
|
||||||
|
|
||||||
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
|
cryptonight_single_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
|
||||||
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
|
cryptonight_double_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
|
||||||
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
|
cryptonight_single_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
|
cryptonight_double_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
|
cryptonight_triple_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
|
||||||
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
|
cryptonight_quad_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_IBPC>,
|
cryptonight_penta_hash<CRYPTONIGHT_LITE, false, VARIANT_IPBC>,
|
||||||
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
|
cryptonight_triple_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
|
cryptonight_quad_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IBPC>,
|
cryptonight_penta_hash<CRYPTONIGHT_LITE, true, VARIANT_IPBC>,
|
||||||
|
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool MultiWorker<N>::selfTest()
|
||||||
return false;
|
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;
|
return memcmp(m_hash, test_output_ipbc_lite, sizeof m_hash) == 0;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
Loading…
Reference in a new issue