From 29d5b0cf7bc2004387a5e48950b5a3bcfb1548d1 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Mon, 13 Jan 2025 02:38:58 -0500 Subject: [PATCH] Improve CScraperManifest::ToJson() to display project all cpid total credits --- src/gridcoin/scraper/scraper_net.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gridcoin/scraper/scraper_net.cpp b/src/gridcoin/scraper/scraper_net.cpp index 1b7f89687e..99d402e2ab 100644 --- a/src/gridcoin/scraper/scraper_net.cpp +++ b/src/gridcoin/scraper/scraper_net.cpp @@ -870,12 +870,36 @@ UniValue CScraperManifest::ToJson() const EXCLUSIVE_LOCKS_REQUIRED(CSplitBlob::c r.pushKV("BeaconList_c", (int64_t) BeaconList_c); UniValue projects(UniValue::VARR); + UniValue project_all_cpid_total_credits(UniValue::VARR); + + std::map total_credit_map; + for (const dentry& part : this->projects) { - projects.push_back(part.ToJson()); + UniValue project(UniValue::VOBJ); + + if (part.project != "ProjectsAllCpidTotalCredits") { + projects.push_back(part.ToJson()); + + } else { + CDataStream ss(SER_NETWORK, 1); + + ss << vParts[part.part1]->data; + + ss >> total_credit_map; + + for (const auto& iter : total_credit_map) { + UniValue tc_entry(UniValue::VOBJ); + + tc_entry.pushKV("project", iter.second); + + project_all_cpid_total_credits.push_back(tc_entry); + } + } } r.pushKV("projects", projects); + r.pushKV("project_all_cpid_total_credits", project_all_cpid_total_credits); UniValue parts(UniValue::VARR); for (const CPart* part : this->vParts)