@@ -401,19 +401,24 @@ std::optional<Cpid> FallbackToCpidByEmail(
401401// ! \param projects Map of local projects loaded from BOINC's client_state.xml
402402// ! file.
403403// !
404- void DetectSplitCpid (const MiningProjectMap& projects)
404+ bool DetectSplitCpid (const MiningProjectMap& projects)
405405{
406406 std::unordered_map<Cpid, std::string> eligible_cpids;
407+ bool has_split_cpid = false ;
407408
408409 for (const auto & project_pair : projects) {
409410 if (project_pair.second .Eligible ()) {
410411 eligible_cpids.emplace (
411412 project_pair.second .m_cpid ,
412413 project_pair.second .m_name );
413414 }
415+
416+ if (project_pair.second .m_error == MiningProject::Error::MISMATCHED_CPID) {
417+ has_split_cpid = true ;
418+ }
414419 }
415420
416- if (eligible_cpids.size () > 1 ) {
421+ if (has_split_cpid || eligible_cpids.size () > 1 ) {
417422 std::string warning = " WARNING: Detected potential CPID split. " ;
418423 warning += " Eligible CPIDs: \n " ;
419424
@@ -423,7 +428,11 @@ void DetectSplitCpid(const MiningProjectMap& projects)
423428 }
424429
425430 LogPrintf (" %s" , warning);
431+
432+ return true ;
426433 }
434+
435+ return false ;
427436}
428437
429438// !
@@ -1046,10 +1055,13 @@ Researcher::Researcher()
10461055Researcher::Researcher (
10471056 MiningId mining_id,
10481057 MiningProjectMap projects,
1049- const GRC::BeaconError beacon_error)
1058+ const GRC::BeaconError beacon_error,
1059+ const bool has_split_cpid
1060+ )
10501061 : m_mining_id(std::move(mining_id))
10511062 , m_projects(std::move(projects))
10521063 , m_beacon_error(beacon_error)
1064+ , m_has_split_cpid(has_split_cpid)
10531065{
10541066}
10551067
@@ -1205,15 +1217,17 @@ void Researcher::Reload(MiningProjectMap projects, GRC::BeaconError beacon_error
12051217 }
12061218 }
12071219
1220+ bool has_split_cpid = false ;
1221+
12081222 if (const CpidOption cpid = mining_id.TryCpid ()) {
1209- DetectSplitCpid (projects);
1223+ has_split_cpid = DetectSplitCpid (projects);
12101224 LogPrintf (" Selected primary CPID: %s" , cpid->ToString ());
12111225 } else if (!projects.empty ()) {
12121226 LogPrintf (" WARNING: no projects eligible for research rewards." );
12131227 }
12141228
12151229 StoreResearcher (
1216- Researcher (std::move (mining_id), std::move (projects), beacon_error));
1230+ Researcher (std::move (mining_id), std::move (projects), beacon_error, has_split_cpid ));
12171231}
12181232
12191233void Researcher::Refresh ()
@@ -1361,6 +1375,11 @@ GRC::BeaconError Researcher::BeaconError() const
13611375 return m_beacon_error;
13621376}
13631377
1378+ bool Researcher::hasSplitCpid () const
1379+ {
1380+ return m_has_split_cpid;
1381+ }
1382+
13641383bool Researcher::ChangeMode (const ResearcherMode mode, std::string email)
13651384{
13661385 email = ToLower (email);
0 commit comments