@@ -1890,6 +1890,16 @@ bool DownloadProjectRacFilesByCPID(const NN::WhitelistSnapshot& projectWhitelist
18901890 // Check if any verified beacons are now active, and if so, remove from the ScraperVerifiedBeacons map.
18911891 UpdateVerifiedBeaconsFromConsensus (Consensus);
18921892
1893+ if (LogInstance ().WillLogCategory (BCLog::LogFlags::SCRAPER))
1894+ {
1895+ for (const auto & entry : Consensus.mPendingMap )
1896+ {
1897+ _log (logattribute::INFO, " DownloadProjectRacFilesByCPID" , " Pending beacon address "
1898+ + entry.first + " , CPID " + entry.second .cpid + " , "
1899+ + DateTimeStrFormat (" %Y%m%d%H%M%S" , entry.second .timestamp ));
1900+ }
1901+ }
1902+
18931903 for (const auto & prjs : projectWhitelist)
18941904 {
18951905 _log (logattribute::INFO, " DownloadProjectRacFiles" , " Downloading project file for " + prjs.m_name );
@@ -2067,17 +2077,7 @@ bool ProcessProjectRacFileByCPID(const std::string& project, const fs::path& fil
20672077 _log (logattribute::INFO, " ENDLOCK" , " cs_TeamIDMap" );
20682078 }
20692079
2070- ScraperVerifiedBeacons ScraperVerifiedBeacons;
2071-
2072- // Minimize lock time
2073- {
2074- LOCK (cs_VerifiedBeacons);
2075- _log (logattribute::INFO, " LOCK" , " cs_VerifiedBeacons" );
2076-
2077- ScraperVerifiedBeacons = GetVerifiedBeacons ();
2078-
2079- _log (logattribute::INFO, " ENDLOCK" , " cs_VerifiedBeacons" );
2080- }
2080+ ScraperVerifiedBeacons LocalVerifiedBeacons;
20812081
20822082 std::string line;
20832083 stringbuilder builder;
@@ -2095,6 +2095,7 @@ bool ProcessProjectRacFileByCPID(const std::string& project, const fs::path& fil
20952095
20962096 // If the CPID is not already active, attempt to verify it if it
20972097 // is pending.
2098+
20982099 if (Consensus.mBeaconMap .count (cpid) < 1 )
20992100 {
21002101 const std::string username = ExtractXML (data, " <name>" , " </name>" );
@@ -2109,10 +2110,14 @@ bool ProcessProjectRacFileByCPID(const std::string& project, const fs::path& fil
21092110 if (iter_pair == Consensus.mPendingMap .end ()) continue ;
21102111 if (iter_pair->second .cpid != cpid) continue ;
21112112
2112- // This copies the pending beacon entry into the VerifiedBeacons map and updates
2113+ // This copies the pending beacon entry into the local VerifiedBeacons map and updates
21132114 // the time entry.
2114- ScraperVerifiedBeacons.mVerifiedMap [iter_pair->first ] = iter_pair->second ;
2115- ScraperVerifiedBeacons.timestamp = GetAdjustedTime ();
2115+ LocalVerifiedBeacons.mVerifiedMap [iter_pair->first ] = iter_pair->second ;
2116+
2117+ _log (logattribute::INFO, " ProcessProjectRacFileByCPID" , " Verified pending beacon for address "
2118+ + iter_pair->first + " , cpid " + iter_pair->second .cpid );
2119+
2120+ LocalVerifiedBeacons.timestamp = GetAdjustedTime ();
21162121 }
21172122
21182123 // Only do this if team membership filtering is specified by network policy.
@@ -2158,9 +2163,40 @@ bool ProcessProjectRacFileByCPID(const std::string& project, const fs::path& fil
21582163 }
21592164 else
21602165 builder.append (line);
2166+ }
21612167
2168+ // Minimize lock time on cs_VerifiedBeacons. The reason that a local temporary map
2169+ // is used above, and then a separate insert loop is used here for the global is to
2170+ // avoid holding the lock for the entire time the while loop processes the user stats
2171+ // file, since for large projects this could be for a relatively long time. (This
2172+ // would be required because to update the global the assignment must be by reference.)
2173+ {
2174+ LOCK (cs_VerifiedBeacons);
2175+ _log (logattribute::INFO, " LOCK" , " cs_VerifiedBeacons" );
2176+
2177+ ScraperVerifiedBeacons& GlobalVerifiedBeacons = GetVerifiedBeacons ();
2178+
2179+ for (const auto & iter_pair : LocalVerifiedBeacons.mVerifiedMap )
2180+ {
2181+ GlobalVerifiedBeacons.mVerifiedMap [iter_pair.first ] = iter_pair.second ;
2182+ }
2183+
2184+ GlobalVerifiedBeacons.timestamp = LocalVerifiedBeacons.timestamp ;
2185+
2186+ if (LogInstance ().WillLogCategory (BCLog::LogFlags::SCRAPER))
2187+ {
2188+ for (const auto & iter_pair : GlobalVerifiedBeacons.mVerifiedMap )
2189+ {
2190+ _log (logattribute::INFO, " ProcessProjectRacFileByCPID" , " Global mVerifiedMap entry "
2191+ + iter_pair.first + " , cpid " + iter_pair.second .cpid );
2192+
2193+ }
2194+ }
2195+
2196+ _log (logattribute::INFO, " ENDLOCK" , " cs_VerifiedBeacons" );
21622197 }
21632198
2199+
21642200 if (bfileerror)
21652201 {
21662202 _log (logattribute::CRITICAL, " ProcessProjectRacFileByCPID" , " Error in data processing of " + file.string () + " ; Aborted processing" );
0 commit comments