Code cleanup.
This commit is contained in:
parent
2b87a10cf2
commit
7d1be2d234
19 changed files with 75 additions and 66 deletions
|
@ -51,10 +51,7 @@
|
|||
|
||||
xmrig::Api::Api(Base *base) :
|
||||
m_base(base),
|
||||
m_id(),
|
||||
m_workerId(),
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch()),
|
||||
m_httpd(nullptr)
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch())
|
||||
{
|
||||
base->addListener(this);
|
||||
|
||||
|
@ -180,9 +177,9 @@ void xmrig::Api::genId(const String &id)
|
|||
uint8_t hash[200];
|
||||
const size_t addrSize = sizeof(interfaces[i].phys_addr);
|
||||
const size_t inSize = (sizeof(APP_KIND) - 1) + addrSize + sizeof(uint16_t);
|
||||
const uint16_t port = static_cast<uint16_t>(m_base->config()->http().port());
|
||||
const auto port = static_cast<uint16_t>(m_base->config()->http().port());
|
||||
|
||||
uint8_t *input = new uint8_t[inSize]();
|
||||
auto*input = new uint8_t[inSize]();
|
||||
memcpy(input, &port, sizeof(uint16_t));
|
||||
memcpy(input + sizeof(uint16_t), interfaces[i].phys_addr, addrSize);
|
||||
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, (sizeof(APP_KIND) - 1));
|
||||
|
|
|
@ -70,10 +70,10 @@ private:
|
|||
void genWorkerId(const String &id);
|
||||
|
||||
Base *m_base;
|
||||
char m_id[32];
|
||||
char m_workerId[128];
|
||||
char m_id[32]{};
|
||||
char m_workerId[128]{};
|
||||
const uint64_t m_timestamp;
|
||||
Httpd *m_httpd;
|
||||
Httpd *m_httpd = nullptr;
|
||||
std::vector<IApiListener *> m_listeners;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "base/api/Httpd.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/Api.h"
|
||||
#include "base/api/Httpd.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpApiResponse.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
|
@ -58,9 +58,7 @@ xmrig::Httpd::Httpd(Base *base) :
|
|||
}
|
||||
|
||||
|
||||
xmrig::Httpd::~Httpd()
|
||||
{
|
||||
}
|
||||
xmrig::Httpd::~Httpd() = default;
|
||||
|
||||
|
||||
bool xmrig::Httpd::start()
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
#define XMRIG_HTTPD_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -44,6 +45,8 @@ class TcpServer;
|
|||
class Httpd : public IBaseListener, public IHttpListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Httpd)
|
||||
|
||||
Httpd(Base *base);
|
||||
~Httpd() override;
|
||||
|
||||
|
|
|
@ -33,6 +33,4 @@ xmrig::ApiRequest::ApiRequest(Source source, bool restricted) :
|
|||
}
|
||||
|
||||
|
||||
xmrig::ApiRequest::~ApiRequest()
|
||||
{
|
||||
}
|
||||
xmrig::ApiRequest::~ApiRequest() = default;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "base/api/interfaces/IApiRequest.h"
|
||||
#include "base/tools/String.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -37,6 +38,8 @@ namespace xmrig {
|
|||
class ApiRequest : public IApiRequest
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(ApiRequest)
|
||||
|
||||
ApiRequest(Source source, bool restricted);
|
||||
~ApiRequest() override;
|
||||
|
||||
|
@ -63,8 +66,8 @@ protected:
|
|||
String m_rpcMethod;
|
||||
|
||||
private:
|
||||
bool m_restricted;
|
||||
Source m_source;
|
||||
const bool m_restricted;
|
||||
const Source m_source;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue