From 46f25809cca99a4c916f97c81d62b1b400e3357c Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 12 Oct 2018 19:59:40 +0700 Subject: [PATCH] #167 Fixed wrong hashrate in "GET /1/threads" endpoint/ --- src/api/ApiRouter.cpp | 14 ++++++-------- src/api/ApiRouter.h | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/api/ApiRouter.cpp b/src/api/ApiRouter.cpp index d2741799..c17075d3 100644 --- a/src/api/ApiRouter.cpp +++ b/src/api/ApiRouter.cpp @@ -70,11 +70,6 @@ ApiRouter::ApiRouter(xmrig::Controller *controller) : } -ApiRouter::~ApiRouter() -{ -} - - void ApiRouter::ApiRouter::get(const xmrig::HttpRequest &req, xmrig::HttpReply &reply) const { rapidjson::Document doc; @@ -291,13 +286,16 @@ void ApiRouter::getThreads(rapidjson::Document &doc) const const std::vector &threads = m_controller->config()->threads(); rapidjson::Value list(rapidjson::kArrayType); + size_t i = 0; for (const xmrig::IThread *thread : threads) { 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); + hashrate.PushBack(normalize(hr->calc(i, Hashrate::ShortInterval)), allocator); + hashrate.PushBack(normalize(hr->calc(i, Hashrate::MediumInterval)), allocator); + hashrate.PushBack(normalize(hr->calc(i, Hashrate::LargeInterval)), allocator); + + i++; value.AddMember("hashrate", hashrate, allocator); list.PushBack(value, allocator); diff --git a/src/api/ApiRouter.h b/src/api/ApiRouter.h index b781d5a2..6ee92206 100644 --- a/src/api/ApiRouter.h +++ b/src/api/ApiRouter.h @@ -44,7 +44,6 @@ class ApiRouter : public xmrig::IControllerListener { public: ApiRouter(xmrig::Controller *controller); - ~ApiRouter(); void get(const xmrig::HttpRequest &req, xmrig::HttpReply &reply) const; void exec(const xmrig::HttpRequest &req, xmrig::HttpReply &reply);