[WIP] Use unified Pools class.
This commit is contained in:
parent
ee667144e8
commit
f6699b5929
7 changed files with 107 additions and 94 deletions
|
@ -155,6 +155,18 @@ bool xmrig::Pool::isCompatible(const Algorithm &algorithm) const
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Pool::isEnabled() const
|
||||
{
|
||||
# ifdef XMRIG_NO_TLS
|
||||
if (isTLS()) {
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
|
||||
return isValid() && algorithm().isValid();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Pool::isEqual(const Pool &other) const
|
||||
{
|
||||
return (m_nicehash == other.m_nicehash
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
inline bool operator==(const Pool &other) const { return isEqual(other); }
|
||||
|
||||
bool isCompatible(const Algorithm &algorithm) const;
|
||||
bool isEnabled() const;
|
||||
bool isEqual(const Pool &other) const;
|
||||
bool parse(const char *url);
|
||||
bool setUserpass(const char *userpass);
|
||||
|
|
|
@ -26,7 +26,56 @@
|
|||
#include "base/net/Pools.h"
|
||||
|
||||
|
||||
xmrig::Pools::Pools() :
|
||||
m_index(0)
|
||||
xmrig::Pools::Pools()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::Pool &xmrig::Pools::current()
|
||||
{
|
||||
if (m_data.empty()) {
|
||||
m_data.push_back(Pool());
|
||||
}
|
||||
|
||||
return m_data.back();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Pools::setUrl(const char *url)
|
||||
{
|
||||
if (m_data.empty() || m_data.back().isValid()) {
|
||||
Pool pool(url);
|
||||
|
||||
if (pool.isValid()) {
|
||||
m_data.push_back(pool);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
current().parse(url);
|
||||
|
||||
return m_data.back().isValid();
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::Pools::active() const
|
||||
{
|
||||
size_t count = 0;
|
||||
for (const Pool &pool : m_data) {
|
||||
if (pool.isEnabled()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Pools::adjust(const Algorithm &algorithm)
|
||||
{
|
||||
for (Pool &pool : m_data) {
|
||||
pool.adjust(algorithm);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,26 @@ class Pools
|
|||
public:
|
||||
Pools();
|
||||
|
||||
inline bool setUserpass(const char *userpass) { return current().setUserpass(userpass); }
|
||||
inline const std::vector<Pool> &data() const { return m_data; }
|
||||
inline void setFingerprint(const char *fingerprint) { current().setFingerprint(fingerprint); }
|
||||
inline void setKeepAlive(bool enable) { setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0); }
|
||||
inline void setKeepAlive(int keepAlive) { current().setKeepAlive(keepAlive); }
|
||||
inline void setNicehash(bool enable) { current().setNicehash(enable); }
|
||||
inline void setPassword(const char *password) { current().setPassword(password); }
|
||||
inline void setRigId(const char *rigId) { current().setRigId(rigId); }
|
||||
inline void setTLS(bool enable) { current().setTLS(enable); }
|
||||
inline void setUser(const char *user) { current().setUser(user); }
|
||||
inline void setVariant(const char *variant) { current().algorithm().parseVariant(variant); }
|
||||
inline void setVariant(int variant) { current().algorithm().parseVariant(variant); }
|
||||
|
||||
bool setUrl(const char *url);
|
||||
size_t active() const;
|
||||
void adjust(const Algorithm &algorithm);
|
||||
|
||||
private:
|
||||
size_t m_index;
|
||||
Pool ¤t();
|
||||
|
||||
std::vector<Pool> m_data;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue