@@ -2230,57 +2230,69 @@ bool ProcessProjectRacFileByCPID(const std::string& project, const fs::path& fil
22302230
22312231 const std::string& cpid = ExtractXML (data, " <cpid>" , " </cpid>" );
22322232
2233- // If the CPID is active, then this is skipped and the CPID is included.
2234- // If it is not active, then check if already verified. If so, then drop through
2235- // and include. If not active and not already verified, then attempt
2236- // to verify by matching the username to the "verification code" from the
2237- // pending beacons. If this is matched then add to the incoming verified
2233+ // Attempt to verify pending beacons by matching the username to the
2234+ // "verification code" from the pending beacon with the same CPID.
2235+ // If this is matched then add to the incoming verified
22382236 // map, but do not add CPID to the statistic (this go 'round).
2239- if (Consensus.mBeaconMap .count (cpid) < 1 )
2237+
2238+ bool active = Consensus.mBeaconMap .count (cpid);
2239+
2240+ bool already_verified = false ;
2241+ for (const auto & entry : GlobalVerifiedBeaconsCopy.mVerifiedMap )
22402242 {
2241- // If not active, then check whether on passed in copy of the
2242- // global verified beacons.
2243- unsigned int already_verified = 0 ;
2244- for (const auto & entry : GlobalVerifiedBeaconsCopy.mVerifiedMap )
2245- {
2246- if (entry.second .cpid == cpid) ++already_verified;
2247- }
2243+ if (entry.second .cpid == cpid) already_verified = true ;
22482244
2249- if (!already_verified)
2250- {
2251- // Attempt to verify.
2245+ break ;
2246+ }
22522247
2253- const std::string username = ExtractXML (data, " <name>" , " </name>" );
2248+ bool just_verified = false ;
2249+ if (!already_verified)
2250+ {
2251+ // Attempt to verify.
22542252
2255- // Base58-encoded beacon verification code sizes fall within:
2256- if (username.size () < 26 || username.size () > 28 ) continue ;
2253+ const std::string username = ExtractXML (data, " <name>" , " </name>" );
22572254
2255+ // Base58-encoded beacon verification code sizes fall within:
2256+ if (username.size () >= 26 && username.size () <= 28 )
2257+ {
22582258 // The username has to be temporarily changed to a "verification code" that is
22592259 // a base58 encoded version of the public key of the pending beacon, so that
22602260 // it will match the mPendingMap entry. This is the crux of the user validation.
22612261 const auto iter_pair = Consensus.mPendingMap .find (username);
22622262
2263- if (iter_pair == Consensus.mPendingMap .end ()) continue ;
2264- if (iter_pair->second .cpid != cpid) continue ;
2265-
2266- // This copies the pending beacon entry into the local VerifiedBeacons map and updates
2267- // the time entry.
2268- IncomingVerifiedBeacons.mVerifiedMap [iter_pair->first ] = iter_pair->second ;
2263+ if (iter_pair != Consensus.mPendingMap .end () && iter_pair->second .cpid == cpid)
2264+ {
2265+ // This copies the pending beacon entry into the local VerifiedBeacons map and updates
2266+ // the time entry.
2267+ IncomingVerifiedBeacons.mVerifiedMap [iter_pair->first ] = iter_pair->second ;
22692268
2270- _log (logattribute::INFO, " ProcessProjectRacFileByCPID" , " Verified pending beacon for verification code "
2271- + iter_pair->first + " , cpid " + iter_pair->second .cpid );
2269+ _log (logattribute::INFO, " ProcessProjectRacFileByCPID" , " Verified pending beacon for verification code "
2270+ + iter_pair->first + " , cpid " + iter_pair->second .cpid );
22722271
2273- IncomingVerifiedBeacons.timestamp = GetAdjustedTime ();
2272+ IncomingVerifiedBeacons.timestamp = GetAdjustedTime ();
22742273
2275- // We do NOT want to add a just verified CPID to the statistics this iteration,
2276- // because we may be halfway through processing the set of projects. Instead, add to the
2277- // incoming verification map (above), which will be handled in the calling function once
2278- // all of the projects are gone through. This will become a verified beacon the next time
2279- // around.
2280- continue ;
2274+ just_verified = true ;
2275+ }
22812276 }
22822277 }
22832278
2279+ // We do NOT want to add a just verified CPID to the statistics this iteration, if it was
2280+ // not already active, because we may be halfway through processing the set of projects.
2281+ // Instead, add to the incoming verification map (above), which will be handled in the
2282+ // calling function once all of the projects are gone through. This will become a verified
2283+ // beacon the next time around. This is potentially confusing... a truth table is in order...
2284+
2285+ // active already verified just verified no stats (continue)
2286+ // false false false true (this is the initial beacon advertise case)
2287+ // false false true true
2288+ // false true false false
2289+ // false true true xxxxx invalid (just verified checks for already)
2290+ // true false false false
2291+ // true true false false
2292+ // true false true false
2293+ // true true true xxxxx invalid (just verified checks for already)
2294+ if (!active && !already_verified) continue ;
2295+
22842296 // Only do this if team membership filtering is specified by network policy.
22852297 if (REQUIRE_TEAM_WHITELIST_MEMBERSHIP)
22862298 {
0 commit comments