Implemented CN-Heavy algo, Algo tests and fixed n-loop variants (#86)

* Debouncing of connection retry when connecting donation server fails
* When PoW variant is set on proxy, it will overrule local set PoW
* Implementation of cn_heavy algo
* Added self test for cn-heavy
* Fixed n-loop variant of powV2 and cn-heavy
* Fixed n-loop variant of powV2 and added cn-heavy for ARM
* Fixing n-loop for arm
* Limited cn-heavy to max hashfactor 3 on higher seltest fails.
* Removed a lot of casts
* Fixed algo selftest
This commit is contained in:
Ben Gräf 2018-04-07 21:20:24 +02:00 committed by GitHub
parent 06bb082041
commit 1ce9d2bf3c
17 changed files with 2682 additions and 450 deletions

View file

@ -23,6 +23,7 @@
*/
#include <log/Log.h>
#include "interfaces/IStrategyListener.h"
#include "net/Client.h"
#include "net/Job.h"
@ -55,20 +56,28 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
Url *url;
#ifndef XMRIG_NO_TLS
if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 8081, userId, nullptr, true, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, true, false, true);
if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) {
url = new Url("donate2.graef.in", 8443, userId, nullptr, true, false, true);
} else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8081 : 443, userId, nullptr, true, false, true);
if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 8081, userId, nullptr, true, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, true, false, true);
} else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8081 : 443, userId, nullptr, true, false, true);
}
}
#else
if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 80 : 443, userId, nullptr, false, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, false, false, true);
if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) {
url = new Url("donate.graef.in", 8443, userId, nullptr, false, false, true);
} else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 80, userId, nullptr, false, false, true);
if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 80 : 443, userId, nullptr, false, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, false, false, true);
} else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 80, userId, nullptr, false, false, true);
}
}
#endif
@ -113,6 +122,11 @@ void DonateStrategy::tick(uint64_t now)
void DonateStrategy::onClose(Client *client, int failures)
{
if (failures == 5) {
LOG_ERR("Failed to connect to donate address. Reschedule.");
uv_timer_stop(&m_timer);
uv_timer_start(&m_timer, DonateStrategy::onSuspendTimer, 1000, 0);
}
}
@ -166,3 +180,9 @@ void DonateStrategy::onTimer(uv_timer_t *handle)
strategy->suspend();
}
void DonateStrategy::onSuspendTimer(uv_timer_t *handle)
{
auto strategy = static_cast<DonateStrategy*>(handle->data);
strategy->suspend();
}