Skip to content

Commit

Permalink
#167 Fixed wrong hashrate in "GET /1/threads" endpoint/
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Oct 12, 2018
1 parent 0cc0453 commit 46f2580
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/api/ApiRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -291,13 +286,16 @@ void ApiRouter::getThreads(rapidjson::Document &doc) const
const std::vector<xmrig::IThread *> &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);
Expand Down
1 change: 0 additions & 1 deletion src/api/ApiRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 46f2580

Please sign in to comment.