Reverted changes in Job (#82)

This commit is contained in:
Ben Gräf 2018-03-29 23:39:06 +02:00 committed by GitHub
parent 0437583331
commit 94e59b1744
3 changed files with 10 additions and 20 deletions

View file

@ -61,8 +61,7 @@ Job::Job(int poolId, bool nicehash) :
m_threadId(-1), m_threadId(-1),
m_size(0), m_size(0),
m_diff(0), m_diff(0),
m_target(0), m_target(0)
m_blob()
{ {
} }

View file

@ -70,6 +70,7 @@ public:
bool operator!=(const Job &other) const; bool operator!=(const Job &other) const;
private: private:
alignas(16) uint8_t m_blob[84]; // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
bool m_nicehash; bool m_nicehash;
int m_poolId; int m_poolId;
@ -79,8 +80,6 @@ private:
uint64_t m_diff; uint64_t m_diff;
uint64_t m_target; uint64_t m_target;
alignas(16) uint8_t m_blob[84]; // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk.
# ifdef XMRIG_PROXY_PROJECT # ifdef XMRIG_PROXY_PROJECT
VAR_ALIGN(16, char m_rawBlob[169]); VAR_ALIGN(16, char m_rawBlob[169]);
VAR_ALIGN(16, char m_rawTarget[17]); VAR_ALIGN(16, char m_rawTarget[17]);

View file

@ -31,15 +31,15 @@
class JobId class JobId
{ {
public: public:
inline JobId() : inline JobId()
m_data()
{ {
memset(m_data, 0, sizeof(m_data));
} }
inline JobId(const char *jobId, size_t sizeFix = 0) inline JobId(const char *id, size_t sizeFix = 0)
{ {
setId(jobId, sizeFix); setId(id, sizeFix);
} }
@ -55,27 +55,19 @@ public:
} }
JobId &operator=(const JobId &other) inline bool setId(const char *id, size_t sizeFix = 0)
{
memcpy(m_data, other.m_data, sizeof(m_data));
return *this;
}
inline bool setId(const char *jobId, size_t sizeFix = 0)
{ {
memset(m_data, 0, sizeof(m_data)); memset(m_data, 0, sizeof(m_data));
if (!jobId) { if (!id) {
return false; return false;
} }
const size_t size = strlen(jobId); const size_t size = strlen(id);
if (size >= sizeof(m_data)) { if (size >= sizeof(m_data)) {
return false; return false;
} }
memcpy(m_data, jobId, size - sizeFix); memcpy(m_data, id, size - sizeFix);
return true; return true;
} }