diff --git a/src/core/CommonConfig.cpp b/src/core/CommonConfig.cpp index a36b65536..5b8a32ab4 100644 --- a/src/core/CommonConfig.cpp +++ b/src/core/CommonConfig.cpp @@ -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; diff --git a/src/donate.h b/src/donate.h index bdf7a00d2..46f26b73e 100644 --- a/src/donate.h +++ b/src/donate.h @@ -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__ */ diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index 6e7da0c4c..f0ec5bde7 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -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)); }