Fix for n/a hashrate in console.

This commit is contained in:
Haifa Bogdan Adnan 2019-09-02 13:50:10 +03:00
parent 37ee7ac66e
commit 291e02adaf
3 changed files with 6 additions and 4 deletions

View file

@ -26,7 +26,8 @@
#include "workers/Handle.h" #include "workers/Handle.h"
Handle::Handle(xmrig::Config *config, xmrig::HasherConfig *hasherConfig, uint32_t offset) : Handle::Handle(int id, xmrig::Config *config, xmrig::HasherConfig *hasherConfig, uint32_t offset) :
m_id(id),
m_offset(offset), m_offset(offset),
m_config(config), m_config(config),
m_hasherConfig(hasherConfig), m_hasherConfig(hasherConfig),

View file

@ -41,7 +41,7 @@ class IWorker;
class Handle class Handle
{ {
public: public:
Handle(xmrig::Config *config, xmrig::HasherConfig *hasherConfig, uint32_t offset); Handle(int id, xmrig::Config *config, xmrig::HasherConfig *hasherConfig, uint32_t offset);
struct HandleArg { struct HandleArg {
Handle *handle; Handle *handle;
@ -52,7 +52,7 @@ public:
void start(void (*callback) (void *)); void start(void (*callback) (void *));
inline std::vector<IWorker *> &workers() { return m_workers; } inline std::vector<IWorker *> &workers() { return m_workers; }
inline size_t hasherId() const { return m_hasherConfig->index(); } inline size_t hasherId() const { return m_id; }
inline size_t parallelism(int workerIdx) const { return m_hasher != nullptr ? m_hasher->parallelism(workerIdx) : 0; } inline size_t parallelism(int workerIdx) const { return m_hasher != nullptr ? m_hasher->parallelism(workerIdx) : 0; }
inline size_t computingThreads() const { return m_hasher != nullptr ? m_hasher->computingThreads() : 0; } inline size_t computingThreads() const { return m_hasher != nullptr ? m_hasher->computingThreads() : 0; }
inline uint32_t offset() const { return m_offset; } inline uint32_t offset() const { return m_offset; }
@ -61,6 +61,7 @@ public:
inline Hasher *hasher() const { return m_hasher; } inline Hasher *hasher() const { return m_hasher; }
private: private:
int m_id;
std::vector<uv_thread_t> m_threads; std::vector<uv_thread_t> m_threads;
std::vector<IWorker *> m_workers; std::vector<IWorker *> m_workers;

View file

@ -167,7 +167,7 @@ bool Workers::start(xmrig::Controller *controller)
uint32_t offset = 0; uint32_t offset = 0;
for (xmrig::HasherConfig *hasherConfig : hashers) { for (xmrig::HasherConfig *hasherConfig : hashers) {
Handle *handle = new Handle(controller->config(), hasherConfig, offset); Handle *handle = new Handle((int)(m_workers.size()), controller->config(), hasherConfig, offset);
if(handle->hasher() != nullptr) { if(handle->hasher() != nullptr) {
offset += handle->computingThreads(); offset += handle->computingThreads();
m_totalThreads += handle->computingThreads(); m_totalThreads += handle->computingThreads();