From b6e8119fc63a1966268598eadb6eb8c494587d56 Mon Sep 17 00:00:00 2001 From: George Alexandre Silva Date: Tue, 26 Sep 2023 01:14:41 -0300 Subject: [PATCH] Fixed wrong pool total hashrate, with jsonfilter --- src/monitor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index 56f13682..1fb58f3d 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -304,14 +304,22 @@ pool_data getPoolData(void){ if (httpCode == HTTP_CODE_OK) { String payload = http.getString(); // Serial.println(payload); - DynamicJsonDocument doc(1024); - deserializeJson(doc, payload); - + StaticJsonDocument<300> filter; + filter["bestDifficulty"] = true; + filter["workersCount"] = true; + filter["workers"][0]["sessionId"] = true; + filter["workers"][0]["hashRate"] = true; + DynamicJsonDocument doc(2048); + deserializeJson(doc, payload, DeserializationOption::Filter(filter)); + //Serial.println(serializeJsonPretty(doc, Serial)); if (doc.containsKey("workersCount")) pData.workersCount = doc["workersCount"].as(); const JsonArray& workers = doc["workers"].as(); float totalhashs = 0; for (const JsonObject& worker : workers) { - totalhashs += worker["hashRate"].as(); + totalhashs += worker["hashRate"].as(); + /* Serial.print(worker["sessionId"].as()+": "); + Serial.print(" - "+worker["hashRate"].as()+": "); + Serial.println(totalhashs); */ } pData.workersHash = String(totalhashs/1000); double temp;