Skip to content

Commit

Permalink
Additional changes to scraper from debugging (to be squashed)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Jan 13, 2025
1 parent 29d5b0c commit 2fe6d02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
28 changes: 10 additions & 18 deletions src/gridcoin/scraper/scraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3937,8 +3937,6 @@ ScraperStatsVerifiedBeaconsTotalCredits GetScraperStatsByConvergedManifest(const
// Enumerate the count of active projects from the dummy converged manifest. One of the parts
// is the beacon list, is not a project, which is why that should not be included in the count.
// Populate the verified beacons map, and if it is don't count that either.
ScraperPendingBeaconMap VerifiedBeaconMap;

int exclude_parts_from_count = 1;

auto iter = StructConvergedManifest.ConvergedManifestPartPtrsMap.find("VerifiedBeacons");
Expand All @@ -3948,7 +3946,7 @@ ScraperStatsVerifiedBeaconsTotalCredits GetScraperStatsByConvergedManifest(const

try
{
part >> VerifiedBeaconMap;
part >> stats_verified_beacons_tc.mVerifiedMap;
}
catch (const std::exception& e)
{
Expand All @@ -3958,18 +3956,14 @@ ScraperStatsVerifiedBeaconsTotalCredits GetScraperStatsByConvergedManifest(const
++exclude_parts_from_count;
}

stats_verified_beacons_tc.mVerifiedMap = VerifiedBeaconMap;

std::map<std::string, double> projects_all_cpid_total_credits_map;

iter = StructConvergedManifest.ConvergedManifestPartPtrsMap.find("ProjectsAllCpidTotalCredits");
if (iter != StructConvergedManifest.ConvergedManifestPartPtrsMap.end())
{
CDataStream part(iter->second->data, SER_NETWORK, 1);

try
{
part >> projects_all_cpid_total_credits_map;
part >> stats_verified_beacons_tc.m_total_credit_map;
}
catch (const std::exception& e)
{
Expand All @@ -3979,8 +3973,6 @@ ScraperStatsVerifiedBeaconsTotalCredits GetScraperStatsByConvergedManifest(const
++exclude_parts_from_count;
}

stats_verified_beacons_tc.m_total_credit_map = projects_all_cpid_total_credits_map;

unsigned int nActiveProjects = StructConvergedManifest.ConvergedManifestPartPtrsMap.size() - exclude_parts_from_count;

// If a project part is greylisted, do not count it as an active project, even though stats have been collected.
Expand Down Expand Up @@ -4660,6 +4652,14 @@ EXCLUSIVE_LOCKS_REQUIRED(cs_StructScraperFileManifest, CScraperManifest::cs_mapM
auto scraper_cmanifest_include_noncurrent_proj_files =
[]() { LOCK(cs_ScraperGlobals); return SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES; };

// Populate the all cpid total credit map from current entries only. Keep track of the timestamps and assign
// the latest manifest file entry timestamp to the total_credit_map_timestamp.
if (entry.second.current && !entry.second.excludefromcsmanifest) {
total_credit_map.insert(std::make_pair(entry.first, entry.second.all_cpid_total_credit));

total_credit_map_timestamp = std::max(entry.second.timestamp, total_credit_map_timestamp);
}

// If SCRAPER_CMANIFEST_INCLUDE_NONCURRENT_PROJ_FILES is false, only include current files to send across the
// network. Also continue (exclude) if it is a non-publishable entry (excludefromcsmanifest is true) or
// if it has no records.
Expand All @@ -4668,14 +4668,6 @@ EXCLUSIVE_LOCKS_REQUIRED(cs_StructScraperFileManifest, CScraperManifest::cs_mapM
continue;
}

// Populate the all cpid total credit map from current entries only. Keep track of the timestamps and assign
// the latest manifest file entry timestamp to the total_credit_map_timestamp.
if (entry.second.current) {
total_credit_map.insert(std::make_pair(entry.first, entry.second.all_cpid_total_credit));

total_credit_map_timestamp = std::max(entry.second.timestamp, total_credit_map_timestamp);
}

fs::path inputfile = entry.first;

fs::path inputfilewpath = pathScraper / inputfile;
Expand Down
6 changes: 2 additions & 4 deletions src/gridcoin/scraper/scraper_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,8 @@ UniValue CScraperManifest::ToJson() const EXCLUSIVE_LOCKS_REQUIRED(CSplitBlob::c
if (part.project != "ProjectsAllCpidTotalCredits") {
projects.push_back(part.ToJson());

} else {
CDataStream ss(SER_NETWORK, 1);

ss << vParts[part.part1]->data;
} else if (!vParts[part.part1]->data.empty()) {
CDataStream ss(vParts[part.part1]->data, SER_NETWORK, 1);

ss >> total_credit_map;

Expand Down

0 comments on commit 2fe6d02

Please sign in to comment.