Skip to content

Commit 7caa624

Browse files
authored
Merge pull request #2020 from jamescowens/beacon_storage_leveldb
beacon: Tweak BeaconRegistry::Revert
2 parents 37a0389 + 84afb78 commit 7caa624

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/gridcoin/beacon.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -582,26 +582,15 @@ void BeaconRegistry::Revert(const ContractContext& ctx)
582582

583583
// If the beacon is a renewal, it will have been put directly into the active beacons map with a status
584584
// of RENEWAL. m_beacons is a map keyed by CPID, so therefore there can be only one record in m_beacons that
585-
// corresponds to the renewed beacon to be deleted.
585+
// corresponds to the renewed beacon to be deleted. It also must be in a status of renewal to be reverted as a
586+
// renewal. Direct add v1 contracts are directly reverted when they are gotten to above.
586587
auto iter = m_beacons.find(payload->m_cpid);
587588

588-
// The beacon exists and has a valid prev beacon hash...
589-
if (iter != m_beacons.end())
589+
// The beacon exists, has a valid prev beacon hash, and is a renewal...
590+
if (iter != m_beacons.end() && iter->second->m_status == BeaconStatusForStorage::RENEWAL)
590591
{
591592
Beacon_ptr renewal = iter->second;
592593

593-
// There had been not be a non-renewal beacon in here at this point because the version 1 contracts
594-
// were handled already above (which are the direct to active from ADD action).
595-
if (renewal->m_status != BeaconStatusForStorage::RENEWAL)
596-
{
597-
error("%s: Transaction hash %s: Beacon to revert for cpid %s in m_beacons map for renewal reversion "
598-
"is not in status of RENEWAL. Statis is %i.",
599-
__func__,
600-
ctx.m_tx.GetHash().GetHex(),
601-
payload->m_cpid.ToString(),
602-
renewal->m_status.Raw());
603-
}
604-
605594
// Check that the identified beacon hash corresponds to the beacon in the transaction context.
606595
if (renewal->m_hash != ctx.m_tx.GetHash())
607596
{
@@ -649,8 +638,6 @@ void BeaconRegistry::Revert(const ContractContext& ctx)
649638
else
650639
{
651640
// This else case should NOT happen because version 1 contracts were handled above. Log an error.
652-
// It would probably happen with the renwal->m_status not in RENEWAL above, because the conditions
653-
// would be coincident.
654641
error("%s: Transaction hash %s: The identified renewal beacon for cpid %s to revert "
655642
"does not have a m_prev_beacon_hash.",
656643
__func__,

0 commit comments

Comments
 (0)