Optimize memory usage.

This commit is contained in:
XMRig
2018-10-22 14:29:10 +07:00
parent 3ce14afdcb
commit 358ee9fd39
4 changed files with 12 additions and 8 deletions

View File

@@ -63,11 +63,13 @@ xmrig::Config::Config() : xmrig::CommonConfig(),
bool xmrig::Config::isTLS() const
{
# ifndef XMRIG_NO_TLS
for (const BindHost &host : m_bind) {
if (host.isTLS()) {
return true;
}
}
# endif
return false;
}

View File

@@ -51,6 +51,7 @@
static int64_t nextId = 0;
char Miner::m_sendBuf[2048] = { 0 };
xmrig::Storage<Miner> Miner::m_storage;
@@ -58,6 +59,7 @@ Miner::Miner(const xmrig::TlsContext *ctx, bool ipv6, uint16_t port) :
m_ipv6(ipv6),
m_nicehash(true),
m_ip(),
m_routeId(-1),
m_id(++nextId),
m_loginId(0),
m_recvBufPos(0),

View File

@@ -56,12 +56,6 @@ public:
ClosingState
};
# ifndef XMRIG_NO_TLS
constexpr static int kInputBufferSize = 1024 * 16;
# else
constexpr static int kInputBufferSize = 1024 * 2;
# endif
Miner(const xmrig::TlsContext *ctx, bool ipv6, uint16_t port);
~Miner();
bool accept(uv_stream_t *server);
@@ -74,6 +68,7 @@ public:
inline const char *password() const { return m_password.data(); }
inline const char *rigId(bool safe = false) const { return (safe ? (m_rigId.size() > 0 ? m_rigId.data() : m_user.data()) : m_rigId.data()); }
inline const char *user() const { return m_user.data(); }
inline int32_t routeId() const { return m_routeId; }
inline int64_t id() const { return m_id; }
inline ssize_t mapperId() const { return m_mapperId; }
inline State state() const { return m_state; }
@@ -90,6 +85,7 @@ public:
inline void setFixedByte(uint8_t fixedByte) { m_fixedByte = fixedByte; }
inline void setMapperId(ssize_t mapperId) { m_mapperId = mapperId; }
inline void setNiceHash(bool nicehash) { m_nicehash = nicehash; }
inline void setRouteId(int32_t id) { m_routeId = id; }
private:
class Tls;
@@ -119,10 +115,10 @@ private:
bool m_ipv6;
bool m_nicehash;
char m_buf[kInputBufferSize];
char m_buf[1024];
char m_ip[46];
char m_rpcId[37];
char m_sendBuf[2048];
int32_t m_routeId;
int64_t m_id;
int64_t m_loginId;
size_t m_recvBufPos;
@@ -145,6 +141,7 @@ private:
xmrig::c_str m_rigId;
xmrig::c_str m_user;
static char m_sendBuf[2048];
static xmrig::Storage<Miner> m_storage;
};

View File

@@ -101,6 +101,9 @@ void Miner::Tls::read(const char *data, size_t size)
send();
read();
}
else {
m_miner->close();
}
return;
}