Merge xmrig v6.9.0 into master

This commit is contained in:
MoneroOcean 2021-02-22 00:24:10 +00:00
commit 158bf879c1
33 changed files with 290 additions and 189 deletions

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -37,6 +37,14 @@ const char *xmrig::Tags::network()
}
const char* xmrig::Tags::origin()
{
static const char* tag = YELLOW_BG_BOLD(WHITE_BOLD_S " origin ");
return tag;
}
const char *xmrig::Tags::signal()
{
static const char *tag = YELLOW_BG_BOLD(WHITE_BOLD_S " signal ");

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -32,6 +32,7 @@ class Tags
public:
static const char *config();
static const char *network();
static const char *origin();
static const char *signal();
# ifdef XMRIG_MINER_PROJECT

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -46,9 +46,11 @@ public:
static void setProcessPriority(int priority);
static void setThreadPriority(int priority);
static inline const String &userAgent() { return m_userAgent; }
static inline bool isUserActive(uint64_t ms) { return idleTime() < ms; }
static inline const String &userAgent() { return m_userAgent; }
static bool isOnBatteryPower();
static uint64_t idleTime();
private:
static char *createUserAgent();

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -107,3 +107,18 @@ bool xmrig::Platform::isOnBatteryPower()
{
return IOPSGetTimeRemainingEstimate() != kIOPSTimeRemainingUnlimited;
}
uint64_t xmrig::Platform::idleTime()
{
uint64_t idle_time = 0;
const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"));
const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time);
CFRelease(property);
IOObjectRelease(service);
return idle_time / 1000000U;
}

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -34,6 +34,7 @@
#include <uv.h>
#include <thread>
#include <fstream>
#include <limits>
#include "base/kernel/Platform.h"
@ -158,3 +159,9 @@ bool xmrig::Platform::isOnBatteryPower()
}
return false;
}
uint64_t xmrig::Platform::idleTime()
{
return std::numeric_limits<uint64_t>::max();
}

View file

@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -21,6 +21,7 @@
#include <winsock2.h>
#include <windows.h>
#include <uv.h>
#include <limits>
#include "base/kernel/Platform.h"
@ -161,3 +162,16 @@ bool xmrig::Platform::isOnBatteryPower()
}
return false;
}
uint64_t xmrig::Platform::idleTime()
{
LASTINPUTINFO info{};
info.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&info)) {
return std::numeric_limits<uint64_t>::max();
}
return static_cast<uint64_t>(GetTickCount() - info.dwTime);
}

View file

@ -1,12 +1,6 @@
/* 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 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -67,7 +61,6 @@ const char *BaseConfig::kColors = "colors";
const char *BaseConfig::kDryRun = "dry-run";
const char *BaseConfig::kHttp = "http";
const char *BaseConfig::kLogFile = "log-file";
const char *BaseConfig::kPauseOnBattery = "pause-on-battery";
const char *BaseConfig::kPrintTime = "print-time";
#ifdef XMRIG_FEATURE_MO_BENCHMARK
const char *BaseConfig::kRebenchAlgo = "rebench-algo";
@ -103,7 +96,6 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
# endif
m_syslog = reader.getBool(kSyslog, m_syslog);
m_watch = reader.getBool(kWatch, m_watch);
m_pauseOnBattery = reader.getBool(kPauseOnBattery, m_pauseOnBattery);
m_logFile = reader.getString(kLogFile);
m_userAgent = reader.getString(kUserAgent);
m_printTime = std::min(reader.getUint(kPrintTime, m_printTime), 3600U);

View file

@ -1,12 +1,6 @@
/* 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 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -61,7 +55,6 @@ public:
static const char *kDryRun;
static const char *kHttp;
static const char *kLogFile;
static const char *kPauseOnBattery;
static const char *kPrintTime;
# ifdef XMRIG_FEATURE_MO_BENCHMARK
static const char *kRebenchAlgo;
@ -81,7 +74,6 @@ public:
inline bool isAutoSave() const { return m_autoSave; }
inline bool isBackground() const { return m_background; }
inline bool isDryRun() const { return m_dryRun; }
inline bool isPauseOnBattery() const { return m_pauseOnBattery; }
inline bool isSyslog() const { return m_syslog; }
inline const char *logFile() const { return m_logFile.data(); }
inline const char *userAgent() const { return m_userAgent.data(); }
@ -114,7 +106,6 @@ protected:
bool m_autoSave = true;
bool m_background = false;
bool m_dryRun = false;
bool m_pauseOnBattery = false;
bool m_syslog = false;
bool m_upgrade = false;
bool m_watch = true;
@ -126,7 +117,7 @@ protected:
String m_logFile;
String m_userAgent;
Title m_title;
uint32_t m_printTime = 60;
uint32_t m_printTime = 60;
# ifdef XMRIG_FEATURE_MO_BENCHMARK
bool m_rebenchAlgo = false;

View file

@ -1,12 +1,6 @@
/* 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 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -269,11 +263,12 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
case IConfig::HttpEnabledKey: /* --http-enabled */
case IConfig::DaemonKey: /* --daemon */
# endif
case IConfig::VerboseKey: /* --verbose */
# ifdef XMRIG_FEATURE_MO_BENCHMARK
case IConfig::RebenchAlgoKey: /* --rebench-algo */
# endif
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
case IConfig::SubmitToOriginKey: /* --submit-to-origin */
case IConfig::VerboseKey: /* --verbose */
return transformBoolean(doc, key, true);
case IConfig::ColorKey: /* --no-color */
@ -302,6 +297,8 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
case IConfig::TlsKey: /* --tls */
return add(doc, Pools::kPools, Pool::kTls, enable);
case IConfig::SubmitToOriginKey: /* --submit-to-origin */
return add(doc, Pools::kPools, Pool::kSubmitToOrigin, enable);
# ifdef XMRIG_FEATURE_HTTP
case IConfig::DaemonKey: /* --daemon */
return add(doc, Pools::kPools, Pool::kDaemon, enable);

View file

@ -1,12 +1,6 @@
/* 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 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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

View file

@ -1,12 +1,6 @@
/* 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 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -86,6 +80,8 @@ public:
BenchTokenKey = 1048,
DmiKey = 1049,
HugePageSizeKey = 1050,
PauseOnActiveKey = 1051,
SubmitToOriginKey = 1052,
// xmrig common
CPUPriorityKey = 1021,

View file

@ -1,13 +1,7 @@
/* 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-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2019 Howard Chu <https://github.com/hyc>
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 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
@ -80,6 +74,7 @@ const char *Pool::kPass = "pass";
const char *Pool::kRigId = "rig-id";
const char *Pool::kSelfSelect = "self-select";
const char *Pool::kSOCKS5 = "socks5";
const char *Pool::kSubmitToOrigin = "submit-to-origin";
const char *Pool::kTls = "tls";
const char *Pool::kUrl = "url";
const char *Pool::kUser = "user";
@ -137,7 +132,8 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
setKeepAlive(Json::getValue(object, kKeepalive));
if (m_daemon.isValid()) {
m_mode = MODE_SELF_SELECT;
m_mode = MODE_SELF_SELECT;
m_submitToOrigin = Json::getBool(object, kSubmitToOrigin, m_submitToOrigin);
}
else if (Json::getBool(object, kDaemon)) {
m_mode = MODE_DAEMON;
@ -237,7 +233,7 @@ xmrig::IClient *xmrig::Pool::createClient(int id, IClientListener *listener) con
client = new DaemonClient(id, listener);
}
else if (m_mode == MODE_SELF_SELECT) {
client = new SelfSelectClient(id, Platform::userAgent(), listener);
client = new SelfSelectClient(id, Platform::userAgent(), listener, m_submitToOrigin);
}
# endif
# ifdef XMRIG_ALGO_KAWPOW
@ -300,7 +296,8 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const
obj.AddMember(StringRef(kDaemonPollInterval), m_pollInterval, allocator);
}
else {
obj.AddMember(StringRef(kSelfSelect), m_daemon.url().toJSON(), allocator);
obj.AddMember(StringRef(kSelfSelect), m_daemon.url().toJSON(), allocator);
obj.AddMember(StringRef(kSubmitToOrigin), m_submitToOrigin, allocator);
}
return obj;
@ -319,7 +316,7 @@ std::string xmrig::Pool::printableName() const
}
if (m_mode == MODE_SELF_SELECT) {
out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + CLEAR;
out += std::string(" self-select ") + CSI "1;" + std::to_string(m_daemon.isTLS() ? 32 : 36) + "m" + m_daemon.url().data() + WHITE_BOLD_S + (m_submitToOrigin ? " submit-to-origin" : "") + CLEAR;
}
return out;

View file

@ -1,13 +1,7 @@
/* 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 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2019 Howard Chu <https://github.com/hyc>
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2020 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
@ -73,6 +67,7 @@ public:
static const char *kRigId;
static const char *kSelfSelect;
static const char *kSOCKS5;
static const char *kSubmitToOrigin;
static const char *kTls;
static const char *kUrl;
static const char *kUser;
@ -144,6 +139,7 @@ private:
void setKeepAlive(const rapidjson::Value &value);
Algorithm m_algorithm;
bool m_submitToOrigin = false;
Coin m_coin;
int m_keepAlive = 0;
Mode m_mode = MODE_AUTO_ETH;

View file

@ -1,13 +1,8 @@
/* 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 2019 jtgrassie <https://github.com/jtgrassie>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2019 jtgrassie <https://github.com/jtgrassie>
* Copyright (c) 2021 Hansie Odendaal <https://github.com/hansieodendaal>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -31,9 +26,12 @@
#include "base/io/json/Json.h"
#include "base/io/json/JsonRequest.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/http/Fetch.h"
#include "base/net/http/HttpData.h"
#include "base/net/stratum/Client.h"
#include "net/JobResult.h"
#include "base/tools/Cvt.h"
namespace xmrig {
@ -54,7 +52,8 @@ static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashin
} /* namespace xmrig */
xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener) :
xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submitToOrigin) :
m_submitToOrigin(submitToOrigin),
m_listener(listener)
{
m_httpListener = std::make_shared<HttpListener>(this);
@ -68,6 +67,16 @@ xmrig::SelfSelectClient::~SelfSelectClient()
}
int64_t xmrig::SelfSelectClient::submit(const JobResult &result)
{
if (m_submitToOrigin) {
submitOriginDaemon(result);
}
return m_client->submit(result);
}
void xmrig::SelfSelectClient::tick(uint64_t now)
{
m_client->tick(now);
@ -201,6 +210,9 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result)
Document doc(kObjectType);
auto &allocator = doc.GetAllocator();
m_blocktemplate = Json::getString(result,kBlocktemplateBlob);
m_blockDiff = Json::getUint64(result, kDifficulty);
Value params(kObjectType);
params.AddMember(StringRef(kId), m_job.clientId().toJSON(), allocator);
params.AddMember(StringRef(kJobId), m_job.id().toJSON(), allocator);
@ -236,6 +248,44 @@ void xmrig::SelfSelectClient::submitBlockTemplate(rapidjson::Value &result)
}
void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result)
{
if (result.diff == 0 || m_blockDiff == 0) {
return;
}
if (result.actualDiff() < m_blockDiff) {
m_originNotSubmitted++;
LOG_DEBUG("%s " RED_BOLD("not submitted to origin daemon, difficulty too low") " (%" PRId64 "/%" PRId64 ") "
BLACK_BOLD(" diff ") BLACK_BOLD("%" PRIu64) BLACK_BOLD(" vs. ") BLACK_BOLD("%" PRIu64),
Tags::origin(), m_originSubmitted, m_originNotSubmitted, m_blockDiff, result.actualDiff());
return;
}
char *data = m_blocktemplate.data();
Cvt::toHex(data + 78, 8, reinterpret_cast<const uint8_t*>(&result.nonce), 4);
using namespace rapidjson;
Document doc(kObjectType);
Value params(kArrayType);
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
JsonRequest::create(doc, m_sequence, "submitblock", params);
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend);
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
fetch(tag(), std::move(req), m_httpListener);
m_originSubmitted++;
LOG_INFO("%s " GREEN_BOLD("submitted to origin daemon") " (%" PRId64 "/%" PRId64 ") "
" diff " WHITE("%" PRIu64) " vs. " WHITE("%" PRIu64),
Tags::origin(), m_originSubmitted, m_originNotSubmitted, m_blockDiff, result.actualDiff(), result.diff);
// Ensure that the latest block template is available after block submission
getBlockTemplate();
}
void xmrig::SelfSelectClient::onHttpData(const HttpData &data)
{
if (data.status != HTTP_STATUS_OK) {

View file

@ -1,13 +1,8 @@
/* 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 2019 jtgrassie <https://github.com/jtgrassie>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2019 jtgrassie <https://github.com/jtgrassie>
* Copyright (c) 2021 Hansie Odendaal <https://github.com/hansieodendaal>
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
@ -31,9 +26,9 @@
#include "base/kernel/interfaces/IClientListener.h"
#include "base/net/http/HttpListener.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Object.h"
#include <map>
#include <memory>
@ -45,7 +40,7 @@ class SelfSelectClient : public IClient, public IClientListener, public IHttpLis
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(SelfSelectClient)
SelfSelectClient(int id, const char *agent, IClientListener *listener);
SelfSelectClient(int id, const char *agent, IClientListener *listener, bool submitToOrigin);
~SelfSelectClient() override;
protected:
@ -65,7 +60,6 @@ protected:
inline int64_t send(const rapidjson::Value &obj, Callback callback) override { return m_client->send(obj, callback); }
inline int64_t send(const rapidjson::Value &obj) override { return m_client->send(obj); }
inline int64_t sequence() const override { return m_client->sequence(); }
inline int64_t submit(const JobResult &result) override { return m_client->submit(result); }
inline void connect() override { m_client->connect(); }
inline void connect(const Pool &pool) override { m_client->connect(pool); }
inline void deleteLater() override { m_client->deleteLater(); }
@ -77,6 +71,7 @@ protected:
inline void setRetries(int retries) override { m_client->setRetries(retries); m_retries = retries; }
inline void setRetryPause(uint64_t ms) override { m_client->setRetryPause(ms); m_retryPause = ms; }
int64_t submit(const JobResult &result) override;
void tick(uint64_t now) override;
// IClientListener
@ -105,19 +100,26 @@ private:
void retry();
void setState(State state);
void submitBlockTemplate(rapidjson::Value &result);
void submitOriginDaemon(const JobResult &result);
bool m_active = false;
bool m_quiet = false;
bool m_active = false;
bool m_quiet = false;
const bool m_submitToOrigin;
IClient *m_client;
IClientListener *m_listener;
int m_retries = 5;
int64_t m_failures = 0;
int64_t m_sequence = 1;
int m_retries = 5;
int64_t m_failures = 0;
int64_t m_sequence = 1;
Job m_job;
State m_state = IdleState;
State m_state = IdleState;
std::map<int64_t, SubmitResult> m_results;
std::shared_ptr<IHttpListener> m_httpListener;
uint64_t m_retryPause = 5000;
uint64_t m_timestamp = 0;
String m_blocktemplate;
uint64_t m_blockDiff = 0;
uint64_t m_originNotSubmitted = 0;
uint64_t m_originSubmitted = 0;
uint64_t m_retryPause = 5000;
uint64_t m_timestamp = 0;
};