|  | 
| 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() | 
| @@ -1620,14 +1621,99 @@ void BitcoinGUI::updateScraperIcon(int scraperEventtype, int status) | 
| 1620 | 1621 |     else if ((scraperEventtype == (int)scrapereventtypes::Convergence  || scraperEventtype == (int)scrapereventtypes::SBContract) | 
| 1621 | 1622 |              && status == CT_DELETED) | 
| 1622 | 1623 |     { | 
| 1623 |  | -        labelScraperIcon->setPixmap(QIcon(":/icons/red_and_white_x").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1624 | +        labelScraperIcon->setPixmap(QIcon(":/icons/white_and_red_x").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
| 1624 | 1625 |         labelScraperIcon->setToolTip(tr("Scraper: No convergence able to be achieved. Will retry in a few minutes.")); | 
| 1625 | 1626 |     } | 
| 1626 | 1627 | 
 | 
| 1627 | 1628 | } | 
| 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 | +    // Intent is to be an investor. Suppress icon. | 
|  | 1640 | +    if (NN::Researcher::ConfiguredForInvestorMode()) | 
|  | 1641 | +    { | 
|  | 1642 | +        labelBeaconIcon->hide(); | 
|  | 1643 | +    } | 
|  | 1644 | +    // Not configured for investor mode, which means the intent is to be a researcher. | 
|  | 1645 | +    else | 
|  | 1646 | +    { | 
|  | 1647 | +        // Beacon does not exist. | 
|  | 1648 | +        if (sCPID == "INVESTOR") | 
|  | 1649 | +        { | 
|  | 1650 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_red").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1651 | +            labelBeaconIcon->setToolTip(tr("Wallet status is INVESTOR, but the wallet is not configured for investor mode. " | 
|  | 1652 | +                                           "If you intend to be an investor only, please remove the email entry in the config file, " | 
|  | 1653 | +                                           "otherwise you need to check your email entry and your BOINC installation.")); | 
|  | 1654 | +        } | 
|  | 1655 | +        // CPID resolves to non-INVESTOR and beacon exists. | 
|  | 1656 | +        else if (sCPID != "INVESTOR" && beacon_status.hasBeacon) | 
|  | 1657 | +        { | 
|  | 1658 | +            double seconds_in_day = 24.0 * 60.0 * 60.0; | 
|  | 1659 | + | 
|  | 1660 | +            beacon_age = (double) (GetAdjustedTime() - beacon_status.iBeaconTimestamp) / seconds_in_day; | 
|  | 1661 | +            time_to_expiration = ((double) MaxBeaconAge() / seconds_in_day) - beacon_age; | 
|  | 1662 | +            advertise_threshold = BeaconAgeAdvertiseThreshold() / seconds_in_day; | 
|  | 1663 | + | 
|  | 1664 | +            // If beacon does not need to be renewed... | 
|  | 1665 | +            if (beacon_age < advertise_threshold) | 
|  | 1666 | +            { | 
|  | 1667 | +                labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_green").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1668 | +                labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1669 | +                                               "Beacon age: %2 day(s)\n" | 
|  | 1670 | +                                               "Expires: %3 day(s)\n" | 
|  | 1671 | +                                               "Beacon status is good.").arg(QString(sCPID.c_str())) | 
|  | 1672 | +                                            .arg(QString(std::to_string((int) std::round(beacon_age)).c_str())) | 
|  | 1673 | +                                            .arg(QString(std::to_string((int) time_to_expiration).c_str()))); | 
|  | 1674 | +            } | 
|  | 1675 | +            // If between start of period where able to renew and 15 days left until expiration, time to renew!... | 
|  | 1676 | +            else if (beacon_age >= advertise_threshold && time_to_expiration > 15.0) | 
|  | 1677 | +            { | 
|  | 1678 | +                labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_yellow").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1679 | +                labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1680 | +                                               "Beacon age: %2 day(s)\n" | 
|  | 1681 | +                                               "Expires: %3 day(s)\n" | 
|  | 1682 | +                                               "Beacon should be renewed.").arg(QString(sCPID.c_str())) | 
|  | 1683 | +                                            .arg(QString(std::to_string((int) std::round(beacon_age)).c_str())) | 
|  | 1684 | +                                            .arg(QString(std::to_string((int) time_to_expiration).c_str()))); | 
|  | 1685 | +            } | 
|  | 1686 | +            // If magnitude is zero (which is common for new beacons and lapsed beacons that have been renewed)... | 
|  | 1687 | +            else if (!beacon_status.dPriorSBMagnitude) | 
|  | 1688 | +            { | 
|  | 1689 | +                labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_yellow").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 | +                                               "Magnitude is zero, which may prevent staking with research rewards." | 
|  | 1694 | +                                               "Please check your magnitude after the next superblock.").arg(QString(sCPID.c_str())) | 
|  | 1695 | +                                            .arg(QString(std::to_string((int) std::round(beacon_age)).c_str())) | 
|  | 1696 | +                                            .arg(QString(std::to_string((int) time_to_expiration).c_str()))); | 
|  | 1697 | +           } | 
|  | 1698 | +            // If only 15 days left to renew, red alert!... | 
|  | 1699 | +            else if (time_to_expiration <= 15.0) | 
|  | 1700 | +            { | 
|  | 1701 | +                labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_red").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1702 | +                labelBeaconIcon->setToolTip(tr("CPID: %1\n" | 
|  | 1703 | +                                               "Beacon age: %2 day(s)\n" | 
|  | 1704 | +                                               "Expires: %3 day(s)\n" | 
|  | 1705 | +                                               "BEACON SHOULD BE RENEWED IMMEDIATELY TO PREVENT LAPSE.").arg(QString(sCPID.c_str())) | 
|  | 1706 | +                                            .arg(QString(std::to_string((int) std::round(beacon_age)).c_str())) | 
|  | 1707 | +                                            .arg(QString(std::to_string((int) time_to_expiration).c_str()))); | 
|  | 1708 | +            } | 
|  | 1709 | +        } | 
|  | 1710 | +        // CPID resolves, but no active beacon present. | 
|  | 1711 | +        else if (sCPID != "INVESTOR"  && !beacon_status.hasBeacon) | 
|  | 1712 | +        { | 
|  | 1713 | +            labelBeaconIcon->setPixmap(QIcon(":/icons/beacon_red").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); | 
|  | 1714 | +            labelBeaconIcon->setToolTip(tr("There is a CPID, %1, but there is no active beacon. " | 
|  | 1715 | +                                           "Your beacon may be expired or never advertised. Please " | 
|  | 1716 | +                                           "advertise a new beacon.").arg(QString(sCPID.c_str()))); | 
|  | 1717 | +        } | 
|  | 1718 | +    } | 
| 1633 | 1719 | } | 
0 commit comments