forked from xmrig/xmrig-proxy
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge xmrig-proxy v6.22.0 into master
- Loading branch information
Showing
14 changed files
with
93 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -49,13 +49,13 @@ int xmrig::App::exec() | |
return 2; | ||
} | ||
|
||
m_signals = std::make_shared<Signals>(this); | ||
|
||
int rc = 0; | ||
if (background(rc)) { | ||
return rc; | ||
} | ||
|
||
m_signals = std::make_shared<Signals>(this); | ||
|
||
rc = m_controller->init(); | ||
if (rc != 0) { | ||
return rc; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> | ||
* Copyright 2016 Jay D Dee <[email protected]> | ||
* 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>, <[email protected]> | ||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -22,7 +22,6 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <cstdlib> | ||
#include <csignal> | ||
#include <cerrno> | ||
|
@@ -55,16 +54,9 @@ bool xmrig::App::background(int &rc) | |
return true; | ||
} | ||
|
||
i = setsid(); | ||
|
||
if (i < 0) { | ||
if (setsid() < 0) { | ||
LOG_ERR("setsid() failed (errno = %d)", errno); | ||
} | ||
|
||
i = chdir("/"); | ||
if (i < 0) { | ||
LOG_ERR("chdir() failed (errno = %d)", errno); | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ class Coin | |
WOWNERO, | ||
ZEPHYR, | ||
TOWNFORGE, | ||
YADA, | ||
MAX | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> | ||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd> | ||
* Copyright 2019 Howard Chu <https://github.com/hyc> | ||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -24,11 +24,9 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <cassert> | ||
#include <cstring> | ||
|
||
|
||
#include "base/net/stratum/Job.h" | ||
#include "base/tools/Alignment.h" | ||
#include "base/tools/Buffer.h" | ||
|
@@ -112,35 +110,69 @@ bool xmrig::Job::setSeedHash(const char *hash) | |
|
||
bool xmrig::Job::setTarget(const char *target) | ||
{ | ||
if (!target) { | ||
return false; | ||
} | ||
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t { | ||
if (algorithm == Algorithm::RX_YADA) { | ||
return strtoull(target, nullptr, 16); | ||
} | ||
|
||
const auto raw = Cvt::fromHex(target, strlen(target)); | ||
const size_t size = raw.size(); | ||
const auto raw = Cvt::fromHex(target, size); | ||
|
||
if (size == 4) { | ||
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data()))); | ||
} | ||
else if (size == 8) { | ||
m_target = *reinterpret_cast<const uint64_t *>(raw.data()); | ||
} | ||
else { | ||
switch (raw.size()) { | ||
case 4: | ||
return 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data()))); | ||
|
||
case 8: | ||
return *reinterpret_cast<const uint64_t *>(raw.data()); | ||
|
||
default: | ||
break; | ||
} | ||
|
||
return 0; | ||
}; | ||
|
||
const size_t size = target ? strlen(target) : 0; | ||
|
||
if (size < 4 || (m_target = parse(target, size, algorithm())) == 0) { | ||
return false; | ||
} | ||
|
||
m_diff = toDiff(m_target); | ||
|
||
# ifdef XMRIG_PROXY_PROJECT | ||
assert(sizeof(m_rawTarget) > (size * 2)); | ||
if (size >= sizeof(m_rawTarget)) { | ||
return false; | ||
} | ||
|
||
memset(m_rawTarget, 0, sizeof(m_rawTarget)); | ||
memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget))); | ||
memcpy(m_rawTarget, target, size); | ||
# endif | ||
|
||
m_diff = toDiff(m_target); | ||
return true; | ||
} | ||
|
||
|
||
size_t xmrig::Job::nonceOffset() const | ||
{ | ||
switch (algorithm().family()) { | ||
case Algorithm::KAWPOW: | ||
return 32; | ||
|
||
case Algorithm::GHOSTRIDER: | ||
return 76; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
if (algorithm() == Algorithm::RX_YADA) { | ||
return 147; | ||
} | ||
|
||
return 39; | ||
} | ||
|
||
|
||
void xmrig::Job::setDiff(uint64_t diff) | ||
{ | ||
m_diff = diff; | ||
|
@@ -171,14 +203,6 @@ void xmrig::Job::setSigKey(const char *sig_key) | |
} | ||
|
||
|
||
int32_t xmrig::Job::nonceOffset() const | ||
{ | ||
auto f = algorithm().family(); | ||
if (f == Algorithm::KAWPOW) return 32; | ||
if (f == Algorithm::GHOSTRIDER) return 76; | ||
return 39; | ||
} | ||
|
||
uint32_t xmrig::Job::getNumTransactions() const | ||
{ | ||
if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> | ||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd> | ||
* Copyright 2019 Howard Chu <https://github.com/hyc> | ||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -27,11 +27,9 @@ | |
#ifndef XMRIG_JOB_H | ||
#define XMRIG_JOB_H | ||
|
||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
|
||
#include "base/crypto/Algorithm.h" | ||
#include "base/tools/Buffer.h" | ||
#include "base/tools/String.h" | ||
|
@@ -63,6 +61,7 @@ class Job | |
bool setBlob(const char *blob); | ||
bool setSeedHash(const char *hash); | ||
bool setTarget(const char *target); | ||
size_t nonceOffset() const; | ||
void setDiff(uint64_t diff); | ||
void setSigKey(const char *sig_key); | ||
|
||
|
@@ -77,7 +76,6 @@ class Job | |
inline const String &poolWallet() const { return m_poolWallet; } | ||
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + nonceOffset()); } | ||
inline const uint8_t *blob() const { return m_blob; } | ||
int32_t nonceOffset() const; | ||
inline size_t nonceSize() const { return (algorithm().family() == Algorithm::KAWPOW) ? 8 : 4; } | ||
inline size_t size() const { return m_size; } | ||
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + nonceOffset()); } | ||
|
@@ -111,7 +109,7 @@ class Job | |
|
||
inline bool operator!=(const Job &other) const { return !isEqual(other); } | ||
inline bool operator==(const Job &other) const { return isEqual(other); } | ||
inline Job &operator=(const Job &other) { copy(other); return *this; } | ||
inline Job &operator=(const Job &other) { if (this != &other) { copy(other); } return *this; } | ||
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; } | ||
|
||
# ifdef XMRIG_FEATURE_BENCHMARK | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> | ||
* Copyright 2016 Jay D Dee <[email protected]> | ||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> | ||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -149,7 +149,7 @@ void xmrig::Miner::setJob(Job &job, int64_t extra_nonce) | |
|
||
if (hasExtension(EXT_NICEHASH)) { | ||
snprintf(m_sendBuf, 4, "%02hhx", m_fixedByte); | ||
memcpy(job.rawBlob() + (job.nonceOffset() + 3)*2, m_sendBuf, 2); | ||
memcpy(job.rawBlob() + (job.nonceOffset() + 3) * 2, m_sendBuf, 2); | ||
} | ||
|
||
m_diff = job.diff(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters