Removed class Id.

This commit is contained in:
XMRig 2019-03-15 02:03:01 +07:00
parent ba01f2a9c4
commit 8c362411ef
7 changed files with 26 additions and 124 deletions

View file

@ -33,7 +33,6 @@ set(HEADERS
src/base/kernel/Process.h
src/base/kernel/Signals.h
src/base/net/stratum/Client.h
src/base/net/stratum/Id.h
src/base/net/stratum/Job.h
src/base/net/stratum/Pool.h
src/base/net/stratum/Pools.h

View file

@ -397,7 +397,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
bool xmrig::Client::parseLogin(const rapidjson::Value &result, int *code)
{
if (!m_rpcId.setId(result["id"].GetString())) {
m_rpcId = result["id"].GetString();
if (m_rpcId.isNull()) {
*code = 1;
return false;
}
@ -498,7 +499,7 @@ int64_t xmrig::Client::send(const rapidjson::Document &doc)
{
using namespace rapidjson;
StringBuffer buffer(0, 512);
StringBuffer buffer(nullptr, 512);
Writer<StringBuffer> writer(buffer);
doc.Accept(writer);

View file

@ -32,7 +32,6 @@
#include <vector>
#include "base/net/stratum/Id.h"
#include "base/net/stratum/Job.h"
#include "base/net/stratum/Pool.h"
#include "base/net/stratum/SubmitResult.h"
@ -155,7 +154,6 @@ private:
char m_sendBuf[2048];
const char *m_agent;
IClientListener *m_listener;
Id m_rpcId;
int m_id;
int m_retries;
int m_retryPause;
@ -166,6 +164,7 @@ private:
SocketState m_state;
std::bitset<EXT_MAX> m_extensions;
std::map<int64_t, SubmitResult> m_results;
String m_rpcId;
Tls *m_tls;
uint64_t m_expire;
uint64_t m_jobs;

View file

@ -1,98 +0,0 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* 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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_ID_H
#define XMRIG_ID_H
#include <string.h>
namespace xmrig {
class Id
{
public:
inline Id() :
m_data()
{
}
inline Id(const char *id, size_t sizeFix = 0)
{
setId(id, sizeFix);
}
inline bool operator==(const Id &other) const
{
return memcmp(m_data, other.m_data, sizeof(m_data)) == 0;
}
inline bool operator!=(const Id &other) const
{
return memcmp(m_data, other.m_data, sizeof(m_data)) != 0;
}
Id &operator=(const Id &other)
{
memcpy(m_data, other.m_data, sizeof(m_data));
return *this;
}
inline bool setId(const char *id, size_t sizeFix = 0)
{
memset(m_data, 0, sizeof(m_data));
if (!id) {
return false;
}
const size_t size = strlen(id);
if (size >= sizeof(m_data)) {
return false;
}
memcpy(m_data, id, size - sizeFix);
return true;
}
inline const char *data() const { return m_data; }
inline bool isValid() const { return *m_data != '\0'; }
private:
char m_data[64];
};
} /* namespace xmrig */
#endif /* XMRIG_ID_H */

View file

@ -65,25 +65,25 @@ xmrig::Job::Job() :
m_threadId(-1),
m_size(0),
m_diff(0),
m_height(0),
m_target(0),
m_blob(),
m_height(0)
m_blob()
{
}
xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Id &clientId) :
xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const String &clientId) :
m_algorithm(algorithm),
m_autoVariant(algorithm.variant() == VARIANT_AUTO),
m_nicehash(nicehash),
m_poolId(poolId),
m_threadId(-1),
m_size(0),
m_clientId(clientId),
m_diff(0),
m_target(0),
m_blob(),
m_height(0),
m_algorithm(algorithm),
m_clientId(clientId)
m_target(0),
m_blob()
{
}

View file

@ -31,8 +31,8 @@
#include <stdint.h>
#include "base/tools/String.h"
#include "common/crypto/Algorithm.h"
#include "base/net/stratum/Id.h"
namespace xmrig {
@ -46,7 +46,7 @@ public:
static constexpr const size_t kMaxBlobSize = 128;
Job();
Job(int poolId, bool nicehash, const Algorithm &algorithm, const Id &clientId);
Job(int poolId, bool nicehash, const Algorithm &algorithm, const String &clientId);
~Job();
bool isEqual(const Job &other) const;
@ -57,10 +57,10 @@ public:
inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return m_size > 0 && m_diff > 0; }
inline bool setId(const char *id) { return m_id.setId(id); }
inline bool setId(const char *id) { return m_id = id; }
inline const Algorithm &algorithm() const { return m_algorithm; }
inline const Id &clientId() const { return m_clientId; }
inline const Id &id() const { return m_id; }
inline const String &clientId() const { return m_clientId; }
inline const String &id() const { return m_id; }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); }
inline const uint8_t *blob() const { return m_blob; }
inline int poolId() const { return m_poolId; }
@ -72,7 +72,7 @@ public:
inline uint64_t target() const { return m_target; }
inline uint8_t fixedByte() const { return *(m_blob + 42); }
inline void reset() { m_size = 0; m_diff = 0; }
inline void setClientId(const Id &id) { m_clientId = id; }
inline void setClientId(const String &id) { m_clientId = id; }
inline void setPoolId(int poolId) { m_poolId = poolId; }
inline void setThreadId(int threadId) { m_threadId = threadId; }
inline void setVariant(const char *variant) { m_algorithm.parseVariant(variant); }
@ -99,18 +99,18 @@ public:
private:
Variant variant() const;
Algorithm m_algorithm;
bool m_autoVariant;
bool m_nicehash;
int m_poolId;
int m_threadId;
size_t m_size;
String m_clientId;
String m_id;
uint64_t m_diff;
uint64_t m_height;
uint64_t m_target;
uint8_t m_blob[kMaxBlobSize];
uint64_t m_height;
xmrig::Algorithm m_algorithm;
xmrig::Id m_clientId;
xmrig::Id m_id;
# ifdef XMRIG_PROXY_PROJECT
char m_rawBlob[kMaxBlobSize * 2 + 8];

View file

@ -31,6 +31,7 @@
#include <stdint.h>
#include "base/tools/String.h"
#include "base/net/stratum/Job.h"
@ -41,11 +42,11 @@ class JobResult
{
public:
inline JobResult() : poolId(0), diff(0), nonce(0) {}
inline JobResult(int poolId, const Id &jobId, const Id &clientId, uint32_t nonce, const uint8_t *result, uint32_t diff, const Algorithm &algorithm) :
inline JobResult(int poolId, const String &jobId, const String &clientId, uint32_t nonce, const uint8_t *result, uint32_t diff, const Algorithm &algorithm) :
algorithm(algorithm),
poolId(poolId),
clientId(clientId),
jobId(jobId),
poolId(poolId),
diff(diff),
nonce(nonce)
{
@ -71,9 +72,9 @@ public:
Algorithm algorithm;
Id clientId;
Id jobId;
int poolId;
String clientId;
String jobId;
uint32_t diff;
uint32_t nonce;
uint8_t result[32];