Options class replaced to xmrig::Config.

This commit is contained in:
XMRig 2018-03-31 16:29:47 +07:00
parent aad19f1a35
commit aac7b0404a
25 changed files with 240 additions and 1104 deletions

View file

@ -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
@ -27,8 +27,10 @@
#include <memory.h>
#include <stdio.h>
#include "core/Config.h"
#include "core/Controller.h"
#include "log/Log.h"
#include "Options.h"
#include "workers/Hashrate.h"
@ -43,9 +45,10 @@ inline const char *format(double h, char* buf, size_t size)
}
Hashrate::Hashrate(int threads) :
Hashrate::Hashrate(int threads, xmrig::Controller *controller) :
m_highest(0.0),
m_threads(threads)
m_threads(threads),
m_controller(controller)
{
m_counts = new uint64_t*[threads];
m_timestamps = new uint64_t*[threads];
@ -60,7 +63,7 @@ Hashrate::Hashrate(int threads) :
memset(m_timestamps[0], 0, sizeof(uint64_t) * kBucketSize);
}
const int printTime = Options::i()->printTime();
const int printTime = controller->config()->printTime();
if (printTime > 0) {
uv_timer_init(uv_default_loop(), &m_timer);
@ -153,7 +156,7 @@ void Hashrate::print()
char num3[8];
char num4[8];
LOG_INFO(Options::i()->colors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m max: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s max: %s H/s",
LOG_INFO(m_controller->config()->isColors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m max: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s max: %s H/s",
format(calc(ShortInterval), num1, sizeof(num1)),
format(calc(MediumInterval), num2, sizeof(num2)),
format(calc(LargeInterval), num3, sizeof(num3)),

View file

@ -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
@ -29,6 +29,11 @@
#include <uv.h>
namespace xmrig {
class Controller;
}
class Hashrate
{
public:
@ -38,7 +43,7 @@ public:
LargeInterval = 900000
};
Hashrate(int threads);
Hashrate(int threads, xmrig::Controller *controller);
double calc(size_t ms) const;
double calc(size_t threadId, size_t ms) const;
void add(size_t threadId, uint64_t count, uint64_t timestamp);
@ -61,6 +66,7 @@ private:
uint64_t** m_counts;
uint64_t** m_timestamps;
uv_timer_t m_timer;
xmrig::Controller *m_controller;
};

View file

@ -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
@ -27,7 +27,6 @@
#include "api/Api.h"
#include "interfaces/IJobResultListener.h"
#include "Mem.h"
#include "Options.h"
#include "workers/DoubleWorker.h"
#include "workers/Handle.h"
#include "workers/Hashrate.h"
@ -103,10 +102,10 @@ void Workers::setJob(const Job &job, bool donate)
}
void Workers::start(int64_t affinity, int priority)
void Workers::start(int64_t affinity, int priority, xmrig::Controller *controller)
{
const int threads = Mem::threads();
m_hashrate = new Hashrate(threads);
m_hashrate = new Hashrate(threads, controller);
uv_mutex_init(&m_mutex);
uv_rwlock_init(&m_rwlock);

View file

@ -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
@ -39,6 +39,11 @@ class Hashrate;
class IJobResultListener;
namespace xmrig {
class Controller;
}
class Workers
{
public:
@ -46,7 +51,7 @@ public:
static void printHashrate(bool detail);
static void setEnabled(bool enabled);
static void setJob(const Job &job, bool donate);
static void start(int64_t affinity, int priority);
static void start(int64_t affinity, int priority, xmrig::Controller *controller);
static void stop();
static void submit(const JobResult &result);