|  | 
| 84 | 84 | #include "contract/polls.h" | 
| 85 | 85 | #include "contract/contract.h" | 
| 86 | 86 | #include "neuralnet/researcher.h" | 
|  | 87 | +#include "beacon.h" | 
| 87 | 88 | 
 | 
| 88 | 89 | #include <iostream> | 
| 89 | 90 | #include <boost/algorithm/string/case_conv.hpp> // for to_lower() | 
| @@ -1628,6 +1629,70 @@ void BitcoinGUI::updateScraperIcon(int scraperEventtype, int status) | 
| 1628 | 1629 | 
 | 
| 1629 | 1630 | void BitcoinGUI::updateBeaconIcon() | 
| 1630 | 1631 | { | 
| 1631 |  | -    labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_green").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
| 1632 |  | -    labelBeaconIcon->setToolTip(tr("Iconsize = %1.").arg(QString(std::to_string(STATUSBAR_ICONSIZE).c_str()))); | 
|  | 1632 | +    std::string sCPID; | 
|  | 1633 | +    double beacon_age = 0; | 
|  | 1634 | +    double time_to_expiration = 0; | 
|  | 1635 | +    double advertise_threshold = 0; | 
|  | 1636 | + | 
|  | 1637 | +    BeaconStatus beacon_status = GetBeaconStatus(sCPID); | 
|  | 1638 | + | 
|  | 1639 | +    if (sCPID == "INVESTOR") | 
|  | 1640 | +    { | 
|  | 1641 | +        labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_grey").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1642 | +        labelBeaconIcon->setToolTip(tr("Wallet status is INVESTOR. No beacon required. If this is not expected, " | 
|  | 1643 | +                                       "please check your email entry in the config file and your BOINC installation.").arg(QString(sCPID.c_str()))); | 
|  | 1644 | +    } | 
|  | 1645 | + | 
|  | 1646 | +    if (beacon_status.hasBeacon) | 
|  | 1647 | +    { | 
|  | 1648 | +        beacon_age = (double) (GetAdjustedTime() - beacon_status.iBeaconTimestamp) / (double) (24 * 60 * 60); | 
|  | 1649 | +        time_to_expiration = (double) (MaxBeaconAge() - beacon_age) / (24 * 60 * 60); | 
|  | 1650 | +        advertise_threshold = BeaconAgeAdvertiseThreshold() / (24 * 60 * 60); | 
|  | 1651 | + | 
|  | 1652 | +        // If beacon does not need to be renewed... | 
|  | 1653 | +        if (beacon_age < advertise_threshold) | 
|  | 1654 | +        { | 
|  | 1655 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_green").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1656 | +            labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1657 | +                                           "Beacon age: %2 day(s)" | 
|  | 1658 | +                                           "Expires: %3 day(s)\n" | 
|  | 1659 | +                                           "Beacon status is good.").arg(QString(sCPID.c_str())) | 
|  | 1660 | +                                        .arg(QString(std::to_string(std::round(beacon_age)).c_str())) | 
|  | 1661 | +                                        .arg(QString(std::to_string(std::round(time_to_expiration)).c_str()))); | 
|  | 1662 | +        } | 
|  | 1663 | +        // If between start of period where able to renew and 15 days left until expiration... (time to renew!) | 
|  | 1664 | +        else if (beacon_age >= advertise_threshold && time_to_expiration > 15.0) | 
|  | 1665 | +        { | 
|  | 1666 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_yellow").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1667 | +            labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1668 | +                                           "Beacon age: %2 day(s)\n" | 
|  | 1669 | +                                           "Expires: %3 day(s)\n" | 
|  | 1670 | +                                           "Beacon should be renewed.").arg(QString(sCPID.c_str())) | 
|  | 1671 | +                                        .arg(QString(std::to_string(std::round(beacon_age)).c_str())) | 
|  | 1672 | +                                        .arg(QString(std::to_string(std::round(time_to_expiration)).c_str()))); | 
|  | 1673 | +        } | 
|  | 1674 | +        // If magnitude is zero (which is common for new beacons and lapsed beacons that have been renewed)... | 
|  | 1675 | +        else if (!beacon_status.dPriorSBMagnitude) | 
|  | 1676 | +        { | 
|  | 1677 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_yellow").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1678 | +            labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1679 | +                                           "Beacon age: %2 day(s)\n" | 
|  | 1680 | +                                           "Expires: %3 day(s)\n" | 
|  | 1681 | +                                           "Magnitude is zero, which may prevent staking with research rewards." | 
|  | 1682 | +                                           "Please check your magnitude after the next superblock.").arg(QString(sCPID.c_str())) | 
|  | 1683 | +                                        .arg(QString(std::to_string(std::round(beacon_age)).c_str())) | 
|  | 1684 | +                                        .arg(QString(std::to_string(std::round(time_to_expiration)).c_str()))); | 
|  | 1685 | +       } | 
|  | 1686 | +        // If only 15 days left to renew, red alert!) | 
|  | 1687 | +        else if (time_to_expiration <= 15.0) | 
|  | 1688 | +        { | 
|  | 1689 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_red").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1690 | +            labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1691 | +                                           "Beacon age: %2 day(s)\n" | 
|  | 1692 | +                                           "Expires: %3 day(s)\n" | 
|  | 1693 | +                                           "BEACON SHOULD BE RENEWED IMMEDIATELY TO PREVENT LAPSE.").arg(QString(sCPID.c_str())) | 
|  | 1694 | +                                        .arg(QString(std::to_string(std::round(beacon_age)).c_str())) | 
|  | 1695 | +                                        .arg(QString(std::to_string(std::round(time_to_expiration)).c_str()))); | 
|  | 1696 | +        } | 
|  | 1697 | +    } | 
| 1633 | 1698 | } | 
0 commit comments