diff --git a/src/api/ApiRouter.cpp b/src/api/ApiRouter.cpp index 08cd9bf6..b8caac9c 100644 --- a/src/api/ApiRouter.cpp +++ b/src/api/ApiRouter.cpp @@ -250,7 +250,7 @@ void ApiRouter::getMiner(rapidjson::Document &doc) const doc.AddMember("ua", rapidjson::StringRef(Platform::userAgent()), allocator); doc.AddMember("cpu", cpu, allocator); doc.AddMember("algo", rapidjson::StringRef(m_controller->config()->algoName()), allocator); - doc.AddMember("hugepages", false, allocator); + doc.AddMember("hugepages", Workers::hugePages() > 0, allocator); doc.AddMember("donate_level", m_controller->config()->donateLevel(), allocator); } @@ -283,12 +283,21 @@ void ApiRouter::getThreads(rapidjson::Document &doc) const { doc.SetObject(); auto &allocator = doc.GetAllocator(); + const Hashrate *hr = Workers::hashrate(); const std::vector &threads = m_controller->config()->threads(); rapidjson::Value list(rapidjson::kArrayType); for (const xmrig::IThread *thread : threads) { - list.PushBack(thread->toAPI(doc), allocator); + rapidjson::Value value = thread->toAPI(doc); + + rapidjson::Value hashrate(rapidjson::kArrayType); + hashrate.PushBack(normalize(hr->calc(thread->index(), Hashrate::ShortInterval)), allocator); + hashrate.PushBack(normalize(hr->calc(thread->index(), Hashrate::MediumInterval)), allocator); + hashrate.PushBack(normalize(hr->calc(thread->index(), Hashrate::LargeInterval)), allocator); + + value.AddMember("hashrate", hashrate, allocator); + list.PushBack(value, allocator); } doc.AddMember("threads", list, allocator); diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index 068c4258..82ad54eb 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -66,6 +66,26 @@ Job Workers::job() } +size_t Workers::hugePages() +{ + uv_mutex_lock(&m_mutex); + const size_t hugePages = m_status.hugePages; + uv_mutex_unlock(&m_mutex); + + return hugePages; +} + + +size_t Workers::threads() +{ + uv_mutex_lock(&m_mutex); + const size_t threads = m_status.threads; + uv_mutex_unlock(&m_mutex); + + return threads; +} + + void Workers::printHashrate(bool detail) { m_hashrate->print(); diff --git a/src/workers/Workers.h b/src/workers/Workers.h index 0dce78b6..f96aa2ca 100644 --- a/src/workers/Workers.h +++ b/src/workers/Workers.h @@ -49,6 +49,8 @@ class Workers { public: static Job job(); + static size_t hugePages(); + static size_t threads(); static void printHashrate(bool detail); static void setEnabled(bool enabled); static void setJob(const Job &job, bool donate); @@ -60,7 +62,6 @@ public: static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; } static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed) == 1; } static inline Hashrate *hashrate() { return m_hashrate; } - static inline size_t threads() { return m_status.threads; } static inline uint64_t sequence() { return m_sequence.load(std::memory_order_relaxed); } static inline void pause() { m_active = false; m_paused = 1; m_sequence++; } static inline void setListener(IJobResultListener *listener) { m_listener = listener; }