mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-17 00:07:44 +00:00
Randomized donation start time.
This commit is contained in:
parent
8aa73318c8
commit
673a1291e1
3 changed files with 13 additions and 7 deletions
|
@ -4,8 +4,8 @@
|
|||
* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
*
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2016-2018 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,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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue