diff --git a/src/donate.h b/src/donate.h index 3a0009486..e8230b870 100644 --- a/src/donate.h +++ b/src/donate.h @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2017 XMRig - * + * Copyright 2017-2018 XMR-Stak , + * Copyright 2016-2018 XMRig , * * 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,6 +31,7 @@ * Percentage of your hashing power that you want to donate to the developer, can be 0 if you don't want to do that. * Example of how it works for the default setting of 1: * You miner will mine into your usual pool for 99 minutes, then switch to the developer's pool for 1 minute. + * Since v2.5.1 start time randomized in range from 50 to 150 minutes minus donation time. * Switching is instant, and only happens after a successful connection, so you never loose any hashes. * * If you plan on changing this setting to 0 please consider making a one off donation to my wallet: diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index ca2f94ca2..ae707e21f 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -41,6 +41,11 @@ const static char *kDonatePool1 = "miner.fee.xmrig.com"; const static char *kDonatePool2 = "emergency.fee.xmrig.com"; +static inline int random(int min, int max){ + return min + rand() / (RAND_MAX / (max - min + 1) + 1); +} + + DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyListener *listener) : m_active(false), m_donateTime(level * 60 * 1000), @@ -69,7 +74,7 @@ DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyL m_timer.data = this; uv_timer_init(uv_default_loop(), &m_timer); - idle(); + idle(random(3000, 9000) * 1000 - m_donateTime); } @@ -132,9 +137,9 @@ void DonateStrategy::onResultAccepted(IStrategy *strategy, Client *client, const } -void DonateStrategy::idle() +void DonateStrategy::idle(uint64_t timeout) { - uv_timer_start(&m_timer, DonateStrategy::onTimer, m_idleTime, 0); + uv_timer_start(&m_timer, DonateStrategy::onTimer, timeout, 0); } @@ -145,7 +150,7 @@ void DonateStrategy::suspend() m_active = false; m_listener->onPause(this); - idle(); + idle(m_idleTime); } diff --git a/src/net/strategies/DonateStrategy.h b/src/net/strategies/DonateStrategy.h index 9d7566f90..4ef299587 100644 --- a/src/net/strategies/DonateStrategy.h +++ b/src/net/strategies/DonateStrategy.h @@ -61,7 +61,7 @@ protected: void onResultAccepted(IStrategy *strategy, Client *client, const SubmitResult &result, const char *error) override; private: - void idle(); + void idle(uint64_t timeout); void suspend(); static void onTimer(uv_timer_t *handle);