Skip to content

Commit

Permalink
Improve CScraperManifest::ToJson() to display project all cpid total …
Browse files Browse the repository at this point in the history
…credits
  • Loading branch information
jamescowens committed Jan 13, 2025
1 parent 5092610 commit 29d5b0c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/gridcoin/scraper/scraper_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, double> 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)
Expand Down

0 comments on commit 29d5b0c

Please sign in to comment.