Skip to content

Commit

Permalink
Merge pull request #1819 from cyrossignol/wizard-improvements
Browse files Browse the repository at this point in the history
gui: Add pool/investor pages to researcher wizard
  • Loading branch information
jamescowens authored Aug 11, 2020
2 parents 4734ce5 + 082e2c8 commit e1b2887
Show file tree
Hide file tree
Showing 40 changed files with 2,631 additions and 73 deletions.
15 changes: 15 additions & 0 deletions gridcoinresearch.pro
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/researcher/researcherwizardauthpage.h \
src/qt/researcher/researcherwizardbeaconpage.h \
src/qt/researcher/researcherwizardemailpage.h \
src/qt/researcher/researcherwizardinvestorpage.h \
src/qt/researcher/researcherwizardmodepage.h \
src/qt/researcher/researcherwizardmodedetailpage.h \
src/qt/researcher/researcherwizardpoolpage.h \
src/qt/researcher/researcherwizardpoolsummarypage.h \
src/qt/researcher/researcherwizardprojectspage.h \
src/qt/researcher/researcherwizardsummarypage.h \
src/qt/transactiontablemodel.h \
Expand Down Expand Up @@ -279,6 +284,11 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/researcher/researcherwizardauthpage.cpp \
src/qt/researcher/researcherwizardbeaconpage.cpp \
src/qt/researcher/researcherwizardemailpage.cpp \
src/qt/researcher/researcherwizardinvestorpage.cpp \
src/qt/researcher/researcherwizardmodepage.cpp \
src/qt/researcher/researcherwizardmodedetailpage.cpp \
src/qt/researcher/researcherwizardpoolpage.cpp \
src/qt/researcher/researcherwizardpoolsummarypage.cpp \
src/qt/researcher/researcherwizardprojectspage.cpp \
src/qt/researcher/researcherwizardsummarypage.cpp \
src/qt/transactiontablemodel.cpp \
Expand Down Expand Up @@ -374,6 +384,11 @@ FORMS += \
src/qt/forms/researcherwizardauthpage.ui \
src/qt/forms/researcherwizardbeaconpage.ui \
src/qt/forms/researcherwizardemailpage.ui \
src/qt/forms/researcherwizardinvestorpage.ui \
src/qt/forms/researcherwizardmodepage.ui \
src/qt/forms/researcherwizardmodedetailpage.ui \
src/qt/forms/researcherwizardpoolpage.ui \
src/qt/forms/researcherwizardpoolsummarypage.ui \
src/qt/forms/researcherwizardprojectspage.ui \
src/qt/forms/researcherwizardsummarypage.ui \
src/qt/forms/sendcoinsdialog.ui \
Expand Down
36 changes: 32 additions & 4 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ QT_FORMS_UI = \
qt/forms/researcherwizardauthpage.ui \
qt/forms/researcherwizardbeaconpage.ui \
qt/forms/researcherwizardemailpage.ui \
qt/forms/researcherwizardinvestorpage.ui \
qt/forms/researcherwizardmodepage.ui \
qt/forms/researcherwizardmodedetailpage.ui \
qt/forms/researcherwizardpoolpage.ui \
qt/forms/researcherwizardpoolsummarypage.ui \
qt/forms/researcherwizardprojectspage.ui \
qt/forms/researcherwizardsummarypage.ui \
qt/forms/sendcoinsdialog.ui \
Expand Down Expand Up @@ -137,6 +142,11 @@ QT_MOC_CPP = \
qt/researcher/moc_researcherwizardauthpage.cpp \
qt/researcher/moc_researcherwizardbeaconpage.cpp \
qt/researcher/moc_researcherwizardemailpage.cpp \
qt/researcher/moc_researcherwizardinvestorpage.cpp \
qt/researcher/moc_researcherwizardmodepage.cpp \
qt/researcher/moc_researcherwizardmodedetailpage.cpp \
qt/researcher/moc_researcherwizardpoolpage.cpp \
qt/researcher/moc_researcherwizardpoolsummarypage.cpp \
qt/researcher/moc_researcherwizardprojectspage.cpp \
qt/researcher/moc_researcherwizardsummarypage.cpp

Expand Down Expand Up @@ -189,6 +199,11 @@ GRIDCOINRESEARCH_QT_H = \
qt/researcher/researcherwizardauthpage.h \
qt/researcher/researcherwizardbeaconpage.h \
qt/researcher/researcherwizardemailpage.h \
qt/researcher/researcherwizardinvestorpage.h \
qt/researcher/researcherwizardmodepage.h \
qt/researcher/researcherwizardmodedetailpage.h \
qt/researcher/researcherwizardpoolpage.h \
qt/researcher/researcherwizardpoolsummarypage.h \
qt/researcher/researcherwizardprojectspage.h \
qt/researcher/researcherwizardsummarypage.h \
qt/rpcconsole.h \
Expand Down Expand Up @@ -240,6 +255,11 @@ GRIDCOINRESEARCH_QT_CPP = \
qt/researcher/researcherwizardauthpage.cpp \
qt/researcher/researcherwizardbeaconpage.cpp \
qt/researcher/researcherwizardemailpage.cpp \
qt/researcher/researcherwizardinvestorpage.cpp \
qt/researcher/researcherwizardmodepage.cpp \
qt/researcher/researcherwizardmodedetailpage.cpp \
qt/researcher/researcherwizardpoolpage.cpp \
qt/researcher/researcherwizardpoolsummarypage.cpp \
qt/researcher/researcherwizardprojectspage.cpp \
qt/researcher/researcherwizardsummarypage.cpp \
qt/rpcconsole.cpp \
Expand Down Expand Up @@ -293,6 +313,8 @@ RES_ICONS = \
qt/res/icons/qrcode.png \
qt/res/icons/quit.png \
qt/res/icons/remove.png \
qt/res/icons/round_gray_x.svg \
qt/res/icons/round_green_check.svg \
qt/res/icons/staking_off.svg \
qt/res/icons/staking_on.svg \
qt/res/icons/staking_unable.svg \
Expand Down Expand Up @@ -336,14 +358,20 @@ RES_ICONS = \
qt/res/icons/icons_native/transactions.svg

RES_IMAGES = \
qt/res/images/splash3.png \
qt/res/images/boinc_logo.svg \
qt/res/images/about.svg \
qt/res/images/gridcoin_horizontal.svg \
qt/res/images/about_light.svg \
qt/res/images/boinc_logo.svg \
qt/res/images/boinc_logo_white.svg \
qt/res/images/gridcoin.svg \
qt/res/images/gridcoin_horizontal.svg \
qt/res/images/gridcoin_testnet.svg \
qt/res/images/about_light.svg
qt/res/images/ic_investor_active.svg \
qt/res/images/ic_investor_inactive.svg \
qt/res/images/ic_pool_active.svg \
qt/res/images/ic_pool_inactive.svg \
qt/res/images/ic_solo_active.svg \
qt/res/images/ic_solo_inactive.svg \
qt/res/images/splash3.png

RES_STYLESHEETS = \
qt/res/stylesheets/light_stylesheet.qss \
Expand Down
40 changes: 26 additions & 14 deletions src/neuralnet/researcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,24 @@ ResearcherPtr g_researcher = std::make_shared<Researcher>();
std::atomic<bool> g_researcher_dirty(true);

//!
//! \brief Rewrite the email directive in the configuration file.
//! \brief Rewrite the configuration file to change investor mode and set the
//! email address directive.
//!
//! \param email The email address to update the directive to.
//! \param email The email address to update the directive to. If empty, set
//! the configuration to investor mode.
//!
//! \return \c false if a filesystem error occurs.
//!
bool RewriteConfigurationFileEmail(const std::string& email)
bool RewriteConfigurationFileMode(const ResearcherMode mode, const std::string& email)
{
const fs::path config_file_path = GetConfigFile();
std::string out = strprintf("email=%s\n", email);
std::string out;

if (mode == ResearcherMode::INVESTOR) {
out = "investor=1\n";
} else if (mode == ResearcherMode::SOLO) {
out = strprintf("email=%s\n", email);
}

try {
fsbridge::ifstream config_file_in(config_file_path);
Expand All @@ -61,7 +69,9 @@ bool RewriteConfigurationFileEmail(const std::string& email)
LOCK(cs_main);

while (std::getline(config_file_in, line)) {
if (!boost::starts_with(line, "email=")) {
if (!boost::starts_with(line, "email=")
&& !boost::starts_with(line, "investor="))
{
out += line;
out += "\n";
}
Expand Down Expand Up @@ -445,12 +455,12 @@ void DetectSplitCpid(const MiningProjectMap& projects)
}

if (eligible_cpids.size() > 1) {
std::string warning = "WARNING: Detected potential CPID split.";
std::string warning = "WARNING: Detected potential CPID split. ";
warning += "Eligible CPIDs: \n";

for (const auto& cpid_pair : eligible_cpids) {
warning += " " + cpid_pair.first.ToString();
warning += " (" + cpid_pair.second + ") \n";
warning += " (" + cpid_pair.second + ")\n";
}

LogPrintf("%s", warning);
Expand Down Expand Up @@ -1092,13 +1102,12 @@ void Researcher::Reload()
return;
}

// Don't force an empty email to investor mode for pool detection:
if (Researcher::Email().empty()) {
LogPrintf(
"WARNING: Please set 'email=<your BOINC account email>' in "
"gridcoinresearch.conf. Continuing in investor mode.");

StoreResearcher(Researcher()); // Investor
return;
"gridcoinresearch.conf or 'investor=1' to decline research "
"rewards");
}

LogPrintf("Loading BOINC CPIDs...");
Expand Down Expand Up @@ -1273,21 +1282,24 @@ NN::BeaconError Researcher::BeaconError() const
return m_beacon_error;
}

bool Researcher::UpdateEmail(std::string email)
bool Researcher::ChangeMode(const ResearcherMode mode, std::string email)
{
boost::to_lower(email);

if (email == Email()) {
if (mode == ResearcherMode::INVESTOR && ConfiguredForInvestorMode()) {
return true;
} else if (mode == ResearcherMode::SOLO && email == Email()) {
return true;
}

if (!RewriteConfigurationFileEmail(email)) {
if (!RewriteConfigurationFileMode(mode, email)) {
return false;
}

{
LOCK(cs_main);
ForceSetArg("-email", email);
ForceSetArg("-investor", mode == ResearcherMode::INVESTOR ? "1" : "0");
}

Reload();
Expand Down
17 changes: 15 additions & 2 deletions src/neuralnet/researcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ class Magnitude;
class Project;
class WhitelistSnapshot;

//!
//! \brief Describes how a user prefers to participate in the research reward
//! protocol.
//!
enum class ResearcherMode
{
INVESTOR, //!< Decline participation in the research reward protocol.
POOL, //!< Earn research rewards from a Gridcoin pool.
SOLO, //!< Earn research rewards with a personal BOINC installation.
};

//!
//! \brief Describes the eligibility status for earning rewards as part of the
//! research reward protocol.
Expand Down Expand Up @@ -498,18 +509,20 @@ class Researcher
NN::BeaconError BeaconError() const;

//!
//! \brief Update the node's BOINC account email address used to detect
//! \brief Update how a user prefers to participate in the research reward
//! protocol and set the node's BOINC account email address used to detect
//! whitelisted projects from a BOINC installation.
//!
//! This method rewrites the configuration file for the new email address,
//! re-reads local BOINC projects, and reloads the researcher context.
//!
//! \param mode Describes how the user prefers to participate.
//! \param email The email address to update the directive to.
//!
//! \return \c false if a filesystem error occurs while rewriting the
//! configuration file.
//!
bool UpdateEmail(std::string email);
bool ChangeMode(const ResearcherMode mode, std::string email);

//!
//! \brief Submit a beacon contract to the network for the current CPID.
Expand Down
8 changes: 8 additions & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<file alias="staking_unable">res/icons/staking_unable.svg</file>
<file alias="superblock">res/icons/superblock.svg</file>
<file alias="warning">res/icons/warning.svg</file>
<file alias="round_green_check">res/icons/round_green_check.svg</file>
<file alias="round_gray_x">res/icons/round_gray_x.svg</file>
</qresource>
<qresource prefix="/images">
<file alias="splash">res/images/splash3.png</file>
Expand All @@ -84,6 +86,12 @@
<file alias="gridcoin">res/images/gridcoin.svg</file>
<file alias="about_light">res/images/about_light.svg</file>
<file alias="gridcoin_testnet">res/images/gridcoin_testnet.svg</file>
<file alias="ic_investor_active">res/images/ic_investor_active.svg</file>
<file alias="ic_investor_inactive">res/images/ic_investor_inactive.svg</file>
<file alias="ic_pool_active">res/images/ic_pool_active.svg</file>
<file alias="ic_pool_inactive">res/images/ic_pool_inactive.svg</file>
<file alias="ic_solo_active">res/images/ic_solo_active.svg</file>
<file alias="ic_solo_inactive">res/images/ic_solo_inactive.svg</file>
</qresource>
<qresource prefix="/movies"/>
<qresource prefix="/stylesheets">
Expand Down
35 changes: 35 additions & 0 deletions src/qt/forms/researcherwizard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<property name="options">
<set>QWizard::HaveCustomButton1|QWizard::NoBackButtonOnLastPage|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButtonOnLastPage</set>
</property>
<widget class="ResearcherWizardModePage" name="modePage"/>
<widget class="ResearcherWizardModeDetailPage" name="modeDetailPage"/>
<widget class="ResearcherWizardEmailPage" name="emailPage">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand Down Expand Up @@ -64,6 +66,9 @@
</sizepolicy>
</property>
</widget>
<widget class="ResearcherWizardInvestorPage" name="investorPage"/>
<widget class="ResearcherWizardPoolPage" name="poolPage"/>
<widget class="ResearcherWizardPoolSummaryPage" name="poolSummaryPage"/>
</widget>
<customwidgets>
<customwidget>
Expand Down Expand Up @@ -96,6 +101,36 @@
<header>researcher/researcherwizardauthpage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResearcherWizardModePage</class>
<extends>QWizardPage</extends>
<header>researcher/researcherwizardmodepage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResearcherWizardModeDetailPage</class>
<extends>QWizardPage</extends>
<header>researcher/researcherwizardmodedetailpage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResearcherWizardInvestorPage</class>
<extends>QWizardPage</extends>
<header>researcher/researcherwizardinvestorpage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResearcherWizardPoolPage</class>
<extends>QWizardPage</extends>
<header>researcher/researcherwizardpoolpage.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResearcherWizardPoolSummaryPage</class>
<extends>QWizardPage</extends>
<header>researcher/researcherwizardpoolsummarypage.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down
Loading

0 comments on commit e1b2887

Please sign in to comment.