From c04720c8fe75af79f8c524d0b798567d5d12c130 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sat, 4 Dec 2021 01:20:55 -0700 Subject: [PATCH] Prefer CPID with active beacon for primary CPID In a situation where multiple CPIDs are detected, Researcher should prefer CPIDs with an active beacon over CPIDs without an active beacon when determining its primary CPID. This change will select the first CPID with an active beacon in the project list, or if there is no such CPID, it will select the last CPID in the project list as before. --- src/gridcoin/researcher.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gridcoin/researcher.cpp b/src/gridcoin/researcher.cpp index 232999c9e1..de239de2a3 100644 --- a/src/gridcoin/researcher.cpp +++ b/src/gridcoin/researcher.cpp @@ -1195,6 +1195,12 @@ void Researcher::Reload(MiningProjectMap projects, GRC::BeaconError beacon_error if (mining_id.Which() != MiningId::Kind::CPID) { for (const auto& project_pair : projects) { + // Stop searching if the current mining_id already has an active beacon + const CpidOption cpid = mining_id.TryCpid(); + if (cpid && GetBeaconRegistry().ContainsActive(*cpid)) { + break; + } + TryProjectCpid(mining_id, project_pair.second); } }