Skip to content

Commit

Permalink
Changes to correct beacon history stall (WIP 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Jan 7, 2024
1 parent 4682985 commit 6e39a25
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/gridcoin/beacon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,14 +890,27 @@ void BeaconRegistry::ActivatePending(
auto iter_pair = m_pending.find(id);

if (iter_pair != m_pending.end()) {
// verified_beacons[iter_pair->second->m_cpid] = iter_pair->second;
///*
bool already_found = (verified_beacons.find(iter_pair->second->m_cpid) != verified_beacons.end());

if (already_found) {
LogPrint(LogFlags::BEACON, "INFO: %s: More than one pending beacon verified for the same CPID %s. Overriding previous"
"verified beacon.",
__func__,
iter_pair->second->m_cpid.ToString());
}
//*/

verified_beacons[iter_pair->second->m_cpid] = iter_pair->second;
/*
bool insert_success = verified_beacons.insert(std::make_pair(iter_pair->second->m_cpid, iter_pair->second)).second;
if (!insert_success) {
LogPrint(LogFlags::BEACON, "INFO: %s: Second verified pending beacon found in SB for the same CPID %s.",
__func__,
iter_pair->second->m_cpid.ToString());
}
*/
}
}

Expand Down Expand Up @@ -941,9 +954,8 @@ void BeaconRegistry::ActivatePending(
for (auto iter = m_pending.begin(); iter != m_pending.end(); /* no-op */) {
PendingBeacon pending_beacon(*iter->second);

// If the pending beacon has expired with no action or the pending beacon's CPID is present in the beacon_id_map
// which indicates another pending beacon was activated for the CPID, remove the pending beacon.
if (pending_beacon.PendingExpired(superblock_time) || verified_beacons.find(pending_beacon.m_cpid) != verified_beacons.end()) {
// If the pending beacon has expired with no action remove the pending beacon.
if (pending_beacon.PendingExpired(superblock_time)) {
// Set the expired pending beacon's previous beacon hash to the beacon entry's hash.
pending_beacon.m_previous_hash = pending_beacon.m_hash;

Expand Down

0 comments on commit 6e39a25

Please sign in to comment.