Sync changes.

This commit is contained in:
XMRig 2019-02-08 16:55:21 +07:00
parent a6a0fb965a
commit 1a2aaf210c
10 changed files with 107 additions and 45 deletions

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.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>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 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
@ -43,7 +44,9 @@ DonateStrategy::DonateStrategy(int level, const char *user, xmrig::Algo algo, IS
m_donateTime(level * 60 * 1000),
m_idleTime((100 - level) * 60 * 1000),
m_strategy(nullptr),
m_listener(listener)
m_listener(listener),
m_now(0),
m_stop(0)
{
uint8_t hash[200];
char userId[65] = { 0 };
@ -93,6 +96,12 @@ void DonateStrategy::connect()
}
void DonateStrategy::setAlgo(const xmrig::Algorithm &algo)
{
m_strategy->setAlgo(algo);
}
void DonateStrategy::stop()
{
uv_timer_stop(&m_timer);
@ -102,7 +111,14 @@ void DonateStrategy::stop()
void DonateStrategy::tick(uint64_t now)
{
m_now = now;
m_strategy->tick(now);
if (m_stop && now > m_stop) {
m_strategy->stop();
m_stop = 0;
}
}
@ -119,7 +135,9 @@ void DonateStrategy::onActive(IStrategy *strategy, Client *client)
void DonateStrategy::onJob(IStrategy *strategy, Client *client, const Job &job)
{
m_listener->onJob(this, client, job);
if (isActive()) {
m_listener->onJob(this, client, job);
}
}
@ -142,7 +160,11 @@ void DonateStrategy::idle(uint64_t timeout)
void DonateStrategy::suspend()
{
m_strategy->stop();
# if defined(XMRIG_AMD_PROJECT) || defined(XMRIG_NVIDIA_PROJECT)
m_stop = m_now + 5000;
# else
m_stop = m_now + 500;
# endif
m_active = false;
m_listener->onPause(this);