From 9ddf712bfea3a8d428d14377c2b0389a15fdb1ad Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sat, 19 Aug 2023 19:15:06 -0400 Subject: [PATCH] Add expiry check for pending beacon to hasPendingBeacon method --- src/qt/researcher/researchermodel.cpp | 12 +++++++++++- src/qt/researcher/researchermodel.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/qt/researcher/researchermodel.cpp b/src/qt/researcher/researchermodel.cpp index b75b24dfa9..a6062c50ba 100644 --- a/src/qt/researcher/researchermodel.cpp +++ b/src/qt/researcher/researchermodel.cpp @@ -276,7 +276,17 @@ bool ResearcherModel::hasActiveBeacon() const bool ResearcherModel::hasPendingBeacon() const { - return m_pending_beacon.operator bool(); + if (!m_pending_beacon.operator bool()) { + return false; + } + + // If here, a pending beacon is present. Determine if expired + // while pending. No need to actually clean the pending entry + // up. It will be eventually cleaned by the contract handler via + // the ActivatePending call. + GRC::PendingBeacon pending_beacon(*m_pending_beacon); + + return !pending_beacon.PendingExpired(GetAdjustedTime()); } bool ResearcherModel::hasRenewableBeacon() const diff --git a/src/qt/researcher/researchermodel.h b/src/qt/researcher/researchermodel.h index dd353a9807..8d6b6df341 100644 --- a/src/qt/researcher/researchermodel.h +++ b/src/qt/researcher/researchermodel.h @@ -93,6 +93,11 @@ class ResearcherModel : public QObject bool hasEligibleProjects() const; bool hasPoolProjects() const; bool hasActiveBeacon() const; + + //! + //! \brief hasPendingBeacon returns true if m_pending_beacon is not null and also not expired while pending. + //! \return boolean + //! bool hasPendingBeacon() const; bool hasRenewableBeacon() const; bool beaconExpired() const;