Added DaemonClient.
This commit is contained in:
parent
0d496aaf2f
commit
62012a1a50
20 changed files with 610 additions and 122 deletions
|
@ -29,6 +29,11 @@
|
|||
#include "common/Platform.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
# include "base/net/stratum/DaemonClient.h"
|
||||
#endif
|
||||
|
||||
|
||||
xmrig::FailoverStrategy::FailoverStrategy(const std::vector<Pool> &pools, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||
m_quiet(quiet),
|
||||
m_retries(retries),
|
||||
|
@ -56,7 +61,7 @@ xmrig::FailoverStrategy::FailoverStrategy(int retryPause, int retries, IStrategy
|
|||
|
||||
xmrig::FailoverStrategy::~FailoverStrategy()
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
for (IClient *client : m_pools) {
|
||||
client->deleteLater();
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +69,15 @@ xmrig::FailoverStrategy::~FailoverStrategy()
|
|||
|
||||
void xmrig::FailoverStrategy::add(const Pool &pool)
|
||||
{
|
||||
Client *client = new Client(static_cast<int>(m_pools.size()), Platform::userAgent(), this);
|
||||
const int id = static_cast<int>(m_pools.size());
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
IClient *client = !pool.isDaemon() ? static_cast<IClient *>(new Client(id, Platform::userAgent(), this))
|
||||
: static_cast<IClient *>(new DaemonClient(id, this));
|
||||
# else
|
||||
IClient *client = new Client(id, Platform::userAgent(), this);
|
||||
# endif
|
||||
|
||||
client->setPool(pool);
|
||||
client->setRetries(m_retries);
|
||||
client->setRetryPause(m_retryPause * 1000);
|
||||
|
@ -102,7 +115,7 @@ void xmrig::FailoverStrategy::resume()
|
|||
|
||||
void xmrig::FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
for (IClient *client : m_pools) {
|
||||
client->setAlgo(algo);
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +136,7 @@ void xmrig::FailoverStrategy::stop()
|
|||
|
||||
void xmrig::FailoverStrategy::tick(uint64_t now)
|
||||
{
|
||||
for (Client *client : m_pools) {
|
||||
for (IClient *client : m_pools) {
|
||||
client->tick(now);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
protected:
|
||||
inline bool isActive() const override { return m_active >= 0; }
|
||||
inline Client *client() const override { return active(); }
|
||||
inline IClient *client() const override { return active(); }
|
||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
|
@ -68,7 +68,7 @@ protected:
|
|||
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
||||
|
||||
private:
|
||||
inline Client *active() const { return m_pools[static_cast<size_t>(m_active)]; }
|
||||
inline IClient *active() const { return m_pools[static_cast<size_t>(m_active)]; }
|
||||
|
||||
const bool m_quiet;
|
||||
const int m_retries;
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
int m_active;
|
||||
IStrategyListener *m_listener;
|
||||
size_t m_index;
|
||||
std::vector<Client*> m_pools;
|
||||
std::vector<IClient*> m_pools;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -29,11 +29,26 @@
|
|||
#include "common/Platform.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_HTTP
|
||||
# include "base/net/stratum/DaemonClient.h"
|
||||
#endif
|
||||
|
||||
|
||||
xmrig::SinglePoolStrategy::SinglePoolStrategy(const Pool &pool, int retryPause, int retries, IStrategyListener *listener, bool quiet) :
|
||||
m_active(false),
|
||||
m_listener(listener)
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!pool.isDaemon()) {
|
||||
m_client = new Client(0, Platform::userAgent(), this);
|
||||
}
|
||||
else {
|
||||
m_client = new DaemonClient(0, this);
|
||||
}
|
||||
# else
|
||||
m_client = new Client(0, Platform::userAgent(), this);
|
||||
# endif
|
||||
|
||||
m_client->setPool(pool);
|
||||
m_client->setRetries(retries);
|
||||
m_client->setRetryPause(retryPause * 1000);
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
protected:
|
||||
inline bool isActive() const override { return m_active; }
|
||||
inline Client *client() const override { return m_client; }
|
||||
inline IClient *client() const override { return m_client; }
|
||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
|
@ -63,7 +63,7 @@ protected:
|
|||
|
||||
private:
|
||||
bool m_active;
|
||||
Client *m_client;
|
||||
IClient *m_client;
|
||||
IStrategyListener *m_listener;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue