#519 Fix donation start time randomization.

This commit is contained in:
XMRig 2018-04-08 22:19:21 +07:00
parent eb56c2b56e
commit de83cfd53c
3 changed files with 13 additions and 8 deletions

View file

@ -349,7 +349,7 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
break;
case DonateLevelKey: /* --donate-level */
if (arg >= kMinDonateLevel && arg <= 99) {
if (arg >= kMinimumDonateLevel && arg <= 99) {
m_donateLevel = arg;
}
break;

View file

@ -29,9 +29,14 @@
* Dev donation.
*
* 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.
*
* Example of how it works for the setting of 1%:
* You miner will mine into your usual pool for random time (in range from 49.5 to 148.5 minutes),
* then switch to the developer's pool for 1 minute, then switch again to your pool for 99 minutes
* and then switch agaiin to developer's pool for 1 minute, these rounds will continue until miner working.
*
* Randomised only first round, to prevent waves on the donation pool.
*
* 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:
@ -39,7 +44,7 @@
* BTC: 1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT
*/
constexpr const int kDefaultDonateLevel = 5;
constexpr const int kMinDonateLevel = 1;
constexpr const int kMinimumDonateLevel = 1;
#endif /* __DONATE_H__ */

View file

@ -41,8 +41,8 @@ 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);
static inline float randomf(float min, float max) {
return (max - min) * ((((float) rand()) / (float) RAND_MAX)) + min;
}
@ -78,7 +78,7 @@ DonateStrategy::DonateStrategy(int level, const char *user, int algo, IStrategyL
m_timer.data = this;
uv_timer_init(uv_default_loop(), &m_timer);
idle(random(3000, 9000) * 1000 - m_donateTime);
idle(m_idleTime * randomf(0.5, 1.5));
}