Merge xmrig v6.5.2
This commit is contained in:
commit
77a951a6a4
21 changed files with 197 additions and 43 deletions
|
@ -83,6 +83,7 @@ public:
|
|||
BenchVerifyKey = 1045,
|
||||
BenchSeedKey = 1046,
|
||||
BenchHashKey = 1047,
|
||||
BenchTokenKey = 1048,
|
||||
|
||||
// xmrig common
|
||||
CPUPriorityKey = 1021,
|
||||
|
|
|
@ -70,6 +70,16 @@ bool xmrig::Pools::isEqual(const Pools &other) const
|
|||
}
|
||||
|
||||
|
||||
int xmrig::Pools::donateLevel() const
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
return benchSize() || (m_benchmark && !m_benchmark->id().isEmpty()) ? 0 : m_donateLevel;
|
||||
# else
|
||||
return m_donateLevel;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
xmrig::IStrategy *xmrig::Pools::createStrategy(IStrategyListener *listener) const
|
||||
{
|
||||
if (active() == 1) {
|
||||
|
@ -187,6 +197,27 @@ void xmrig::Pools::print() const
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Pools::toJSON(rapidjson::Value &out, rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_benchmark) {
|
||||
out.AddMember(StringRef(BenchConfig::kBenchmark), m_benchmark->toJSON(doc), allocator);
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
doc.AddMember(StringRef(kDonateLevel), m_donateLevel, allocator);
|
||||
doc.AddMember(StringRef(kDonateOverProxy), m_proxyDonate, allocator);
|
||||
out.AddMember(StringRef(kPools), toJSON(doc), allocator);
|
||||
doc.AddMember(StringRef(kRetries), retries(), allocator);
|
||||
doc.AddMember(StringRef(kRetryPause), retryPause(), allocator);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Pools::setDonateLevel(int level)
|
||||
{
|
||||
if (level >= kMinimumDonateLevel && level <= 99) {
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
Pools();
|
||||
|
||||
inline const std::vector<Pool> &data() const { return m_data; }
|
||||
inline int donateLevel() const { return benchSize() ? 0 : m_donateLevel; }
|
||||
inline int retries() const { return m_retries; }
|
||||
inline int retryPause() const { return m_retryPause; }
|
||||
inline ProxyDonate proxyDonate() const { return m_proxyDonate; }
|
||||
|
@ -67,12 +66,14 @@ public:
|
|||
inline bool operator==(const Pools &other) const { return isEqual(other); }
|
||||
|
||||
bool isEqual(const Pools &other) const;
|
||||
int donateLevel() const;
|
||||
IStrategy *createStrategy(IStrategyListener *listener) const;
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
size_t active() const;
|
||||
uint32_t benchSize() const;
|
||||
void load(const IJsonReader &reader);
|
||||
void print() const;
|
||||
void toJSON(rapidjson::Value &out, rapidjson::Document &doc) const;
|
||||
|
||||
private:
|
||||
void setDonateLevel(int level);
|
||||
|
|
|
@ -54,6 +54,7 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
|||
|
||||
if (!m_benchmark->id().isEmpty()) {
|
||||
m_job.setId(m_benchmark->id());
|
||||
m_job.setBenchToken(m_benchmark->token());
|
||||
m_mode = ONLINE_VERIFY;
|
||||
|
||||
return;
|
||||
|
|
|
@ -57,6 +57,7 @@ xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson
|
|||
m_submit(Json::getBool(object, kSubmit)),
|
||||
m_id(id),
|
||||
m_seed(Json::getString(object, kSeed)),
|
||||
m_token(Json::getString(object, kToken)),
|
||||
m_size(size),
|
||||
m_hash(0)
|
||||
{
|
||||
|
@ -88,16 +89,53 @@ xmrig::BenchConfig *xmrig::BenchConfig::create(const rapidjson::Value &object)
|
|||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::BenchConfig::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
Value out(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
if (m_size == 0) {
|
||||
out.AddMember(StringRef(kSize), 0U, allocator);
|
||||
}
|
||||
else if (m_size < 1000000) {
|
||||
out.AddMember(StringRef(kSize), Value(fmt::format("{}K", m_size / 1000).c_str(), allocator), allocator);
|
||||
}
|
||||
else {
|
||||
out.AddMember(StringRef(kSize), Value(fmt::format("{}M", m_size / 1000000).c_str(), allocator), allocator);
|
||||
}
|
||||
|
||||
out.AddMember(StringRef(kAlgo), m_algorithm.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kSubmit), m_submit, allocator);
|
||||
out.AddMember(StringRef(kVerify), m_id.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kToken), m_token.toJSON(), allocator);
|
||||
out.AddMember(StringRef(kSeed), m_seed.toJSON(), allocator);
|
||||
|
||||
if (m_hash) {
|
||||
out.AddMember(StringRef(kHash), Value(fmt::format("{:016X}", m_hash).c_str(), allocator), allocator);
|
||||
}
|
||||
else {
|
||||
out.AddMember(StringRef(kHash), kNullType, allocator);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
|
||||
{
|
||||
if (!benchmark) {
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const auto size = strtoul(benchmark, nullptr, 10);
|
||||
if (size < 1 || size > 10) {
|
||||
return false;
|
||||
if (size >= 1 && size <= 10) {
|
||||
return strcasecmp(benchmark, fmt::format("{}M", size).c_str()) == 0 ? size * 1000000 : 0;
|
||||
}
|
||||
|
||||
return strcasecmp(benchmark, fmt::format("{}M", size).c_str()) == 0 ? size * 1000000 : 0;
|
||||
if (size == 250 || size == 500) {
|
||||
return strcasecmp(benchmark, fmt::format("{}K", size).c_str()) == 0 ? size * 1000 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -57,9 +57,12 @@ public:
|
|||
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||
inline const String &id() const { return m_id; }
|
||||
inline const String &seed() const { return m_seed; }
|
||||
inline const String &token() const { return m_token; }
|
||||
inline uint32_t size() const { return m_size; }
|
||||
inline uint64_t hash() const { return m_hash; }
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
|
||||
private:
|
||||
static uint32_t getSize(const char *benchmark);
|
||||
|
||||
|
@ -67,6 +70,7 @@ private:
|
|||
bool m_submit;
|
||||
String m_id;
|
||||
String m_seed;
|
||||
String m_token;
|
||||
uint32_t m_size;
|
||||
uint64_t m_hash;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue