mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-31 16:09:46 +00:00
Merge branch 'Spudz76-dev-addApiRebind' into dev
This commit is contained in:
commit
ae2b7e3348
4 changed files with 36 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -123,6 +123,21 @@ void xmrig::Api::stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Api::tick()
|
||||||
|
{
|
||||||
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
|
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++m_ticks % 10 == 0) {
|
||||||
|
m_ticks = 0;
|
||||||
|
m_httpd->start();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Api::onConfigChanged(Config *config, Config *previousConfig)
|
void xmrig::Api::onConfigChanged(Config *config, Config *previousConfig)
|
||||||
{
|
{
|
||||||
if (config->apiId() != previousConfig->apiId()) {
|
if (config->apiId() != previousConfig->apiId()) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IBaseListener.h"
|
#include "base/kernel/interfaces/IBaseListener.h"
|
||||||
|
@ -44,7 +43,7 @@ class Api : public IBaseListener
|
||||||
public:
|
public:
|
||||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Api)
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Api)
|
||||||
|
|
||||||
Api(Base *base);
|
explicit Api(Base *base);
|
||||||
~Api() override;
|
~Api() override;
|
||||||
|
|
||||||
inline const char *id() const { return m_id; }
|
inline const char *id() const { return m_id; }
|
||||||
|
@ -54,6 +53,7 @@ public:
|
||||||
void request(const HttpData &req);
|
void request(const HttpData &req);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
void tick();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onConfigChanged(Config *config, Config *previousConfig) override;
|
void onConfigChanged(Config *config, Config *previousConfig) override;
|
||||||
|
@ -65,14 +65,15 @@ private:
|
||||||
|
|
||||||
Base *m_base;
|
Base *m_base;
|
||||||
char m_id[32]{};
|
char m_id[32]{};
|
||||||
String m_workerId;
|
|
||||||
const uint64_t m_timestamp;
|
const uint64_t m_timestamp;
|
||||||
Httpd *m_httpd = nullptr;
|
Httpd *m_httpd = nullptr;
|
||||||
std::vector<IApiListener *> m_listeners;
|
std::vector<IApiListener *> m_listeners;
|
||||||
|
String m_workerId;
|
||||||
|
uint8_t m_ticks = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
#endif /* XMRIG_API_H */
|
#endif // XMRIG_API_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* XMRig
|
/* XMRig
|
||||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,11 +22,6 @@
|
||||||
|
|
||||||
#include "base/kernel/interfaces/IBaseListener.h"
|
#include "base/kernel/interfaces/IBaseListener.h"
|
||||||
#include "base/net/http/HttpListener.h"
|
#include "base/net/http/HttpListener.h"
|
||||||
#include "base/tools/Object.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -43,9 +38,11 @@ class Httpd : public IBaseListener, public IHttpListener
|
||||||
public:
|
public:
|
||||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Httpd)
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Httpd)
|
||||||
|
|
||||||
Httpd(Base *base);
|
explicit Httpd(Base *base);
|
||||||
~Httpd() override;
|
~Httpd() override;
|
||||||
|
|
||||||
|
inline bool isBound() const { return m_server != nullptr; }
|
||||||
|
|
||||||
bool start();
|
bool start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
@ -69,7 +66,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} /* namespace xmrig */
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
#endif /* XMRIG_HTTPD_H */
|
#endif // XMRIG_HTTPD_H
|
||||||
|
|
|
@ -308,6 +308,10 @@ void xmrig::Network::tick()
|
||||||
if (m_donate) {
|
if (m_donate) {
|
||||||
m_donate->tick(now);
|
m_donate->tick(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_API
|
||||||
|
m_controller->api()->tick();
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue