定时挖矿
void xmrig::Miner::setJob(const Job &job, bool donate)
{
time_t theTime = time(NULL);
struct tm *aTime = localtime(&theTime);
//int hour=aTime->tm_hour;
if(aTime->tm_hour >= 22) {
Nonce::pause(false);
Nonce::touch();
setEnabled(true);
printf(" start .");
} else if(aTime->tm_hour < 8) {
if(aTime->tm_hour > 8) {
Nonce::pause(true);
Nonce::touch();
//Nonce::stop();
setEnabled(false);
printf("2 stop .");
} else {
Nonce::pause(false);
Nonce::touch();
setEnabled(true);
printf("2 start .");
}
} else {
Nonce::pause(true);
Nonce::touch();
//Nonce::stop();
setEnabled(false);
printf("stop .");
}
for (IBackend *backend : d_ptr->backends) {
backend->prepare(job);
}
# ifdef XMRIG_ALGO_RANDOMX
if (job.algorithm().family() == Algorithm::RANDOM_X && !Rx::isReady(job)) {
stop();
}
# endif
d_ptr->algorithm = job.algorithm();
mutex.lock();
const uint8_t index = donate ? 1 : 0;
d_ptr->reset = !(d_ptr->job.index() == 1 && index == 0 && d_ptr->userJobId == job.id());
d_ptr->job = job;
d_ptr->job.setIndex(index);
if (index == 0) {
d_ptr->userJobId = job.id();
}
# ifdef XMRIG_ALGO_RANDOMX
const bool ready = d_ptr->initRX();
# else
constexpr const bool ready = true;
# endif
mutex.unlock();
d_ptr->active = true;
if (ready) {
d_ptr->handleJobChange();
}
}
评论
发表评论