Move network classes into xmrig namespace.
This commit is contained in:
parent
dbdcc14672
commit
ee667144e8
42 changed files with 481 additions and 332 deletions
|
@ -5,7 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -62,7 +63,7 @@ void Api::exec(const xmrig::HttpRequest &req, xmrig::HttpReply &reply)
|
|||
}
|
||||
|
||||
|
||||
void Api::tick(const NetworkState &network)
|
||||
void Api::tick(const xmrig::NetworkState &network)
|
||||
{
|
||||
if (!m_router) {
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -21,8 +22,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __API_H__
|
||||
#define __API_H__
|
||||
#ifndef XMRIG_API_H
|
||||
#define XMRIG_API_H
|
||||
|
||||
|
||||
#include <uv.h>
|
||||
|
@ -30,13 +31,13 @@
|
|||
|
||||
class ApiRouter;
|
||||
class Hashrate;
|
||||
class NetworkState;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
class Controller;
|
||||
class HttpReply;
|
||||
class HttpRequest;
|
||||
class NetworkState;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,10 +48,10 @@ public:
|
|||
static void release();
|
||||
|
||||
static void exec(const xmrig::HttpRequest &req, xmrig::HttpReply &reply);
|
||||
static void tick(const NetworkState &results);
|
||||
static void tick(const xmrig::NetworkState &results);
|
||||
|
||||
private:
|
||||
static ApiRouter *m_router;
|
||||
};
|
||||
|
||||
#endif /* __API_H__ */
|
||||
#endif /* XMRIG_API_H */
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -119,7 +120,7 @@ void ApiRouter::exec(const xmrig::HttpRequest &req, xmrig::HttpReply &reply)
|
|||
}
|
||||
|
||||
|
||||
void ApiRouter::tick(const NetworkState &network)
|
||||
void ApiRouter::tick(const xmrig::NetworkState &network)
|
||||
{
|
||||
m_network = network;
|
||||
}
|
||||
|
@ -133,7 +134,7 @@ void ApiRouter::onConfigChanged(xmrig::Config *config, xmrig::Config *previousCo
|
|||
|
||||
void ApiRouter::finalize(xmrig::HttpReply &reply, rapidjson::Document &doc) const
|
||||
{
|
||||
rapidjson::StringBuffer buffer(0, 4096);
|
||||
rapidjson::StringBuffer buffer(nullptr, 4096);
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||
writer.SetMaxDecimalPlaces(10);
|
||||
doc.Accept(writer);
|
||||
|
@ -173,7 +174,7 @@ void ApiRouter::genId(const char *id)
|
|||
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, strlen(APP_KIND));
|
||||
|
||||
xmrig::keccak(input, inSize, hash);
|
||||
Job::toHex(hash, 8, m_id);
|
||||
xmrig::Job::toHex(hash, 8, m_id);
|
||||
|
||||
delete [] input;
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -21,8 +22,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __APIROUTER_H__
|
||||
#define __APIROUTER_H__
|
||||
#ifndef XMRIG_APIROUTER_H
|
||||
#define XMRIG_APIROUTER_H
|
||||
|
||||
|
||||
#include "api/NetworkState.h"
|
||||
|
@ -44,12 +45,12 @@ class ApiRouter : public xmrig::IControllerListener
|
|||
{
|
||||
public:
|
||||
ApiRouter(xmrig::Controller *controller);
|
||||
~ApiRouter();
|
||||
~ApiRouter() override;
|
||||
|
||||
void get(const xmrig::HttpRequest &req, xmrig::HttpReply &reply) const;
|
||||
void exec(const xmrig::HttpRequest &req, xmrig::HttpReply &reply);
|
||||
|
||||
void tick(const NetworkState &results);
|
||||
void tick(const xmrig::NetworkState &results);
|
||||
|
||||
protected:
|
||||
void onConfigChanged(xmrig::Config *config, xmrig::Config *previousConfig) override;
|
||||
|
@ -68,8 +69,8 @@ private:
|
|||
|
||||
char m_id[32];
|
||||
char m_workerId[128];
|
||||
NetworkState m_network;
|
||||
xmrig::NetworkState m_network;
|
||||
xmrig::Controller *m_controller;
|
||||
};
|
||||
|
||||
#endif /* __APIROUTER_H__ */
|
||||
#endif /* XMRIG_APIROUTER_H */
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "common/net/SubmitResult.h"
|
||||
|
||||
|
||||
NetworkState::NetworkState() :
|
||||
xmrig::NetworkState::NetworkState() :
|
||||
diff(0),
|
||||
accepted(0),
|
||||
failures(0),
|
||||
|
@ -44,13 +44,13 @@ NetworkState::NetworkState() :
|
|||
}
|
||||
|
||||
|
||||
int NetworkState::connectionTime() const
|
||||
int xmrig::NetworkState::connectionTime() const
|
||||
{
|
||||
return m_active ? (int)((uv_now(uv_default_loop()) - m_connectionTime) / 1000) : 0;
|
||||
}
|
||||
|
||||
|
||||
uint32_t NetworkState::avgTime() const
|
||||
uint32_t xmrig::NetworkState::avgTime() const
|
||||
{
|
||||
if (m_latency.empty()) {
|
||||
return 0;
|
||||
|
@ -60,7 +60,7 @@ uint32_t NetworkState::avgTime() const
|
|||
}
|
||||
|
||||
|
||||
uint32_t NetworkState::latency() const
|
||||
uint32_t xmrig::NetworkState::latency() const
|
||||
{
|
||||
const size_t calls = m_latency.size();
|
||||
if (calls == 0) {
|
||||
|
@ -74,7 +74,7 @@ uint32_t NetworkState::latency() const
|
|||
}
|
||||
|
||||
|
||||
void NetworkState::add(const SubmitResult &result, const char *error)
|
||||
void xmrig::NetworkState::add(const SubmitResult &result, const char *error)
|
||||
{
|
||||
if (error) {
|
||||
rejected++;
|
||||
|
@ -94,7 +94,7 @@ void NetworkState::add(const SubmitResult &result, const char *error)
|
|||
}
|
||||
|
||||
|
||||
void NetworkState::setPool(const char *host, int port, const char *ip)
|
||||
void xmrig::NetworkState::setPool(const char *host, int port, const char *ip)
|
||||
{
|
||||
snprintf(pool, sizeof(pool) - 1, "%s:%d", host, port);
|
||||
|
||||
|
@ -103,7 +103,7 @@ void NetworkState::setPool(const char *host, int port, const char *ip)
|
|||
}
|
||||
|
||||
|
||||
void NetworkState::stop()
|
||||
void xmrig::NetworkState::stop()
|
||||
{
|
||||
m_active = false;
|
||||
diff = 0;
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* 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
|
||||
|
@ -21,14 +22,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKSTATE_H__
|
||||
#define __NETWORKSTATE_H__
|
||||
#ifndef XMRIG_NETWORKSTATE_H
|
||||
#define XMRIG_NETWORKSTATE_H
|
||||
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class SubmitResult;
|
||||
|
||||
|
||||
|
@ -58,4 +62,8 @@ private:
|
|||
uint64_t m_connectionTime;
|
||||
};
|
||||
|
||||
#endif /* __NETWORKSTATE_H__ */
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_NETWORKSTATE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue