Add IClient and BaseClient.
This commit is contained in:
parent
1bd8d63508
commit
9a6944d694
16 changed files with 291 additions and 146 deletions
|
@ -129,7 +129,7 @@ void xmrig::FailoverStrategy::tick(uint64_t now)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::FailoverStrategy::onClose(Client *client, int failures)
|
||||
void xmrig::FailoverStrategy::onClose(IClient *client, int failures)
|
||||
{
|
||||
if (failures == -1) {
|
||||
return;
|
||||
|
@ -150,7 +150,7 @@ void xmrig::FailoverStrategy::onClose(Client *client, int failures)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::FailoverStrategy::onJobReceived(Client *client, const Job &job, const rapidjson::Value &)
|
||||
void xmrig::FailoverStrategy::onJobReceived(IClient *client, const Job &job, const rapidjson::Value &)
|
||||
{
|
||||
if (m_active == client->id()) {
|
||||
m_listener->onJob(this, client, job);
|
||||
|
@ -158,7 +158,7 @@ void xmrig::FailoverStrategy::onJobReceived(Client *client, const Job &job, cons
|
|||
}
|
||||
|
||||
|
||||
void xmrig::FailoverStrategy::onLoginSuccess(Client *client)
|
||||
void xmrig::FailoverStrategy::onLoginSuccess(IClient *client)
|
||||
{
|
||||
int active = m_active;
|
||||
|
||||
|
@ -179,7 +179,7 @@ void xmrig::FailoverStrategy::onLoginSuccess(Client *client)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::FailoverStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
void xmrig::FailoverStrategy::onResultAccepted(IClient *client, const SubmitResult &result, const char *error)
|
||||
{
|
||||
m_listener->onResultAccepted(this, client, result, error);
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
void add(const Pool &pool);
|
||||
|
||||
protected:
|
||||
inline bool isActive() const override { return m_active >= 0; }
|
||||
inline Client *client() const override { return active(); }
|
||||
inline void onLogin(Client *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
inline bool isActive() const override { return m_active >= 0; }
|
||||
inline Client *client() const override { return active(); }
|
||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
|
@ -62,10 +62,10 @@ protected:
|
|||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
void onClose(Client *client, int failures) override;
|
||||
void onJobReceived(Client *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||
void onLoginSuccess(Client *client) override;
|
||||
void onResultAccepted(Client *client, const SubmitResult &result, const char *error) override;
|
||||
void onClose(IClient *client, int failures) override;
|
||||
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||
void onLoginSuccess(IClient *client) override;
|
||||
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)]; }
|
||||
|
|
|
@ -87,7 +87,7 @@ void xmrig::SinglePoolStrategy::tick(uint64_t now)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::SinglePoolStrategy::onClose(Client *, int)
|
||||
void xmrig::SinglePoolStrategy::onClose(IClient *, int)
|
||||
{
|
||||
if (!isActive()) {
|
||||
return;
|
||||
|
@ -98,20 +98,20 @@ void xmrig::SinglePoolStrategy::onClose(Client *, int)
|
|||
}
|
||||
|
||||
|
||||
void xmrig::SinglePoolStrategy::onJobReceived(Client *client, const Job &job, const rapidjson::Value &)
|
||||
void xmrig::SinglePoolStrategy::onJobReceived(IClient *client, const Job &job, const rapidjson::Value &)
|
||||
{
|
||||
m_listener->onJob(this, client, job);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::SinglePoolStrategy::onLoginSuccess(Client *client)
|
||||
void xmrig::SinglePoolStrategy::onLoginSuccess(IClient *client)
|
||||
{
|
||||
m_active = true;
|
||||
m_listener->onActive(this, client);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::SinglePoolStrategy::onResultAccepted(Client *client, const SubmitResult &result, const char *error)
|
||||
void xmrig::SinglePoolStrategy::onResultAccepted(IClient *client, const SubmitResult &result, const char *error)
|
||||
{
|
||||
m_listener->onResultAccepted(this, client, result, error);
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ public:
|
|||
~SinglePoolStrategy() override;
|
||||
|
||||
protected:
|
||||
inline bool isActive() const override { return m_active; }
|
||||
inline Client *client() const override { return m_client; }
|
||||
inline void onLogin(Client *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
inline bool isActive() const override { return m_active; }
|
||||
inline Client *client() const override { return m_client; }
|
||||
inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {}
|
||||
|
||||
int64_t submit(const JobResult &result) override;
|
||||
void connect() override;
|
||||
|
@ -56,10 +56,10 @@ protected:
|
|||
void stop() override;
|
||||
void tick(uint64_t now) override;
|
||||
|
||||
void onClose(Client *client, int failures) override;
|
||||
void onJobReceived(Client *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||
void onLoginSuccess(Client *client) override;
|
||||
void onResultAccepted(Client *client, const SubmitResult &result, const char *error) override;
|
||||
void onClose(IClient *client, int failures) override;
|
||||
void onJobReceived(IClient *client, const Job &job, const rapidjson::Value ¶ms) override;
|
||||
void onLoginSuccess(IClient *client) override;
|
||||
void onResultAccepted(IClient *client, const SubmitResult &result, const char *error) override;
|
||||
|
||||
private:
|
||||
bool m_active;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue