Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ QT_FORMS_UI = \
qt/forms/researcherwizardauthpage.ui \
qt/forms/researcherwizardbeaconpage.ui \
qt/forms/researcherwizardemailpage.ui \
qt/forms/researcherwizardinvestorpage.ui \
qt/forms/researcherwizardnoncruncherpage.ui \
qt/forms/researcherwizardmodedetailpage.ui \
qt/forms/researcherwizardmodepage.ui \
qt/forms/researcherwizardpoolpage.ui \
Expand Down Expand Up @@ -180,7 +180,7 @@ 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_researcherwizardnoncruncherpage.cpp \
qt/researcher/moc_researcherwizardmodedetailpage.cpp \
qt/researcher/moc_researcherwizardmodepage.cpp \
qt/researcher/moc_researcherwizardpoolpage.cpp \
Expand Down Expand Up @@ -281,7 +281,7 @@ GRIDCOINRESEARCH_QT_H = \
qt/researcher/researcherwizardauthpage.h \
qt/researcher/researcherwizardbeaconpage.h \
qt/researcher/researcherwizardemailpage.h \
qt/researcher/researcherwizardinvestorpage.h \
qt/researcher/researcherwizardnoncruncherpage.h \
qt/researcher/researcherwizardmodedetailpage.h \
qt/researcher/researcherwizardmodepage.h \
qt/researcher/researcherwizardpoolpage.h \
Expand Down Expand Up @@ -371,7 +371,7 @@ GRIDCOINRESEARCH_QT_CPP = \
qt/researcher/researcherwizardauthpage.cpp \
qt/researcher/researcherwizardbeaconpage.cpp \
qt/researcher/researcherwizardemailpage.cpp \
qt/researcher/researcherwizardinvestorpage.cpp \
qt/researcher/researcherwizardnoncruncherpage.cpp \
qt/researcher/researcherwizardmodedetailpage.cpp \
qt/researcher/researcherwizardmodepage.cpp \
qt/researcher/researcherwizardpoolpage.cpp \
Expand Down Expand Up @@ -599,8 +599,8 @@ QT_RES_IMAGES = \
qt/res/images/gridcoin.svg \
qt/res/images/gridcoin_horizontal.svg \
qt/res/images/gridcoin_testnet.svg \
qt/res/images/ic_investor_active.svg \
qt/res/images/ic_investor_inactive.svg \
qt/res/images/ic_noncruncher_active.svg \
qt/res/images/ic_noncruncher_inactive.svg \
qt/res/images/ic_pool_active.svg \
qt/res/images/ic_pool_inactive.svg \
qt/res/images/ic_solo_active.svg \
Expand Down
4 changes: 2 additions & 2 deletions src/gridcoin/claim.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Claim : public IContractPayload
uint32_t m_version = CURRENT_VERSION;

//!
//! \brief Indicates whether the claim is for a researcher or investor.
//! \brief Indicates whether the claim is for a researcher or non-cruncher.
//!
//! If the claim declares research rewards, this field shall contain the
//! external CPID of the researcher. For this case, it must match a CPID
Expand Down Expand Up @@ -122,7 +122,7 @@ class Claim : public IContractPayload
//! \brief The value of the research rewards claimed by the node in units
//! of 1/100000000 GRC.
//!
//! Contains a value of zero for investor claims.
//! Contains a value of zero for non-cruncher claims.
//!
//! Claims do not strictly need to contain the block subsidy or research
//! subsidy values. Nodes will calculate these values anyway to validate
Expand Down
13 changes: 8 additions & 5 deletions src/gridcoin/cpid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ MiningId MiningId::Parse(const std::string& input)
return MiningId();
}

if (input == "INVESTOR" || input == "investor") {
return MiningId::ForInvestor();
std::string input_lc = ToLower(input);

// Investor is a synonym for noncruncher for legacy support.
if (input_lc == "noncruncher" || input_lc == "non-cruncher" || input == "investor") {
return MiningId::ForNoncruncher();
}

if (input.size() == 32) {
Expand Down Expand Up @@ -129,10 +132,10 @@ std::string MiningId::Invalid::ToString() const
}

// -----------------------------------------------------------------------------
// Class: MiningId::Investor
// Class: MiningId::Noncruncher
// -----------------------------------------------------------------------------

std::string MiningId::Investor::ToString() const
std::string MiningId::Noncruncher::ToString() const
{
return "INVESTOR";
return "NONCRUNCHER";
}
32 changes: 16 additions & 16 deletions src/gridcoin/cpid.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ class MiningId
//!
enum class Kind : unsigned char
{
INVALID = 0x00, //!< An empty or invalid CPID.
INVESTOR = 0x01, //!< A CPID that represents a non-researcher.
CPID = 0x02, //!< A valid external CPID.
INVALID = 0x00, //!< An empty or invalid CPID.
NONCRUNCHER = 0x01, //!< A CPID that represents a non-researcher.
CPID = 0x02, //!< A valid external CPID.
};

//!
Expand All @@ -242,14 +242,14 @@ class MiningId

//!
//! \brief A tag type that describes a CPID that represents a non-researcher
//! (an investor without a BOINC CPID).
//! (a non-cruncher, i.e. no CPID).
//!
struct Investor
struct Noncruncher
{
//!
//! \brief Get the string representation of an investor.
//! \brief Get the string representation of an non-cruncher.
//!
//! \return The string literal "INVESTOR".
//! \return The string literal "NONCRUNCHER".
//!
std::string ToString() const;
};
Expand All @@ -273,18 +273,18 @@ class MiningId
//!
//! \brief Initialize a mining ID that represents a non-researcher.
//!
static MiningId ForInvestor()
static MiningId ForNoncruncher()
{
MiningId miningId;
miningId.m_variant = Investor();
miningId.m_variant = Noncruncher();

return miningId;
}

//!
//! \brief Create a mining ID object from its string representation.
//!
//! \param input Hex-encoded bytes of a CPID, or the string "INVESTOR".
//! \param input Hex-encoded bytes of a CPID, or the string "NONCRUNCHER".
//!
//! \return A mining ID object parsed from the input.
//!
Expand Down Expand Up @@ -362,7 +362,7 @@ class MiningId
//!
//! \brief Determine whether the mining ID is valid.
//!
//! \return \c true if the object represents a valid CPID or an investor.
//! \return \c true if the object represents a valid CPID or a non-cruncher.
//!
bool Valid() const
{
Expand All @@ -387,8 +387,8 @@ class MiningId
//!
//! \brief Get the string representation of the mining ID.
//!
//! \return Hex-encoded bytes of the MD5 hash for a CPID, "INVESTOR" for
//! an investor, or an empty string for invalid mining IDs.
//! \return Hex-encoded bytes of the MD5 hash for a CPID, "NONCRUNCHER" for
//! a non-cruncher, or an empty string for invalid mining IDs.
//!
std::string ToString() const;

Expand Down Expand Up @@ -422,8 +422,8 @@ class MiningId
::Unserialize(stream, kind);

switch (static_cast<Kind>(kind)) {
case Kind::INVESTOR:
m_variant = Investor();
case Kind::NONCRUNCHER:
m_variant = Noncruncher();
break;
case Kind::CPID:
{
Expand All @@ -443,7 +443,7 @@ class MiningId
//!
//! \brief Stores the various states that a mining ID may exist in.
//!
std::variant<Invalid, Investor, Cpid> m_variant;
std::variant<Invalid, Noncruncher, Cpid> m_variant;
}; // MiningId
} // namespace GRC

Expand Down
6 changes: 3 additions & 3 deletions src/gridcoin/mrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool TrySignMRC(
const GRC::CpidOption cpid = mrc.m_mining_id.TryCpid();

if (!cpid) {
return false; // Skip beacon signature for investors.
return false; // Skip beacon signature for non-crunchers.
}

const GRC::BeaconOption beacon = GRC::GetBeaconRegistry().Try(*cpid);
Expand Down Expand Up @@ -359,8 +359,8 @@ void GRC::CreateMRC(CBlockIndex* pindex,
break;
case GRC::ResearcherStatus::NO_BEACON:
throw MRC_error(strprintf("%s: CPID eligible but no active beacon key so MRC cannot be formed.", __func__));
case GRC::ResearcherStatus::INVESTOR:
throw MRC_error(strprintf("%s: MRC request cannot be sent while wallet is in investor mode.", __func__));
case GRC::ResearcherStatus::NONCRUNCHER:
throw MRC_error(strprintf("%s: MRC request cannot be sent while wallet is in non-cruncher mode.", __func__));
case GRC::ResearcherStatus::NO_PROJECTS:
// This is handled as no positive research reward pending below.
err = false;
Expand Down
4 changes: 2 additions & 2 deletions src/gridcoin/mrc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MRC : public IContractPayload
uint32_t m_version = CURRENT_VERSION;

//!
//! \brief Indicates whether the claim is for a researcher or investor.
//! \brief Indicates whether the claim is for a researcher or non-cruncher.
//!
//! If the claim declares research rewards, this field shall contain the
//! external CPID of the researcher. For this case, it must match a CPID
Expand Down Expand Up @@ -118,7 +118,7 @@ class MRC : public IContractPayload
//! \brief The value of the research rewards claimed by the node in units
//! of 1/100000000 GRC.
//!
//! Contains a value of zero for investor claims.
//! Contains a value of zero for non-cruncher claims.
//!
//! Claims do not strictly need to contain the block subsidy or research
//! subsidy values. Nodes will calculate these values anyway to validate
Expand Down
2 changes: 1 addition & 1 deletion src/gridcoin/quorum.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Quorum
//! \param cpid May contain a CPID to fetch the magnitude for.
//!
//! \return Magnitude as of the last tallied superblock or zero if the
//! mining ID represents an investor.
//! mining ID represents a non-cruncher.
//!
static Magnitude GetMagnitude(const MiningId mining_id);

Expand Down
55 changes: 30 additions & 25 deletions src/gridcoin/researcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,27 @@ ResearcherPtr g_researcher = std::make_shared<Researcher>();
std::atomic<bool> g_researcher_dirty(true);

//!
//! \brief Change investor mode and set the email address directive in the
//! \brief Change non-cruncher mode and set the email address directive in the
//! read-write JSON settings file
//!
//! \param email The email address to update the directive to. If empty, set
//! the configuration to investor mode.
//! the configuration to non-cruncher mode.
//!
//! \return \c false if an error occurs during the update.
//!
bool UpdateRWSettingsForMode(const ResearcherMode mode, const std::string& email)
{
std::vector<std::pair<std::string, util::SettingsValue>> settings;

if (mode == ResearcherMode::INVESTOR) {
// Ensure old (legacy) investor key is removed.
settings.push_back(std::make_pair("investor", util::SettingsValue(UniValue::VNULL)));

if (mode == ResearcherMode::NONCRUNCHER) {
settings.push_back(std::make_pair("email", util::SettingsValue(UniValue::VNULL)));
settings.push_back(std::make_pair("investor", "1"));
settings.push_back(std::make_pair("noncruncher", "1"));
} else if (mode == ResearcherMode::SOLO) {
settings.push_back(std::make_pair("email", util::SettingsValue(email)));
settings.push_back(std::make_pair("investor", "0"));
settings.push_back(std::make_pair("noncruncher", "0"));
}

return ::updateRwSettings(settings);
Expand Down Expand Up @@ -467,8 +470,8 @@ void StoreResearcher(Researcher context)
case ResearcherStatus::NO_BEACON:
msMiningErrors = _("Staking Only - No active beacon");
break;
case ResearcherStatus::INVESTOR:
msMiningErrors = _("Staking Only - Investor Mode");
case ResearcherStatus::NONCRUNCHER:
msMiningErrors = _("Staking Only - Non-cruncher Mode");
break;
}

Expand Down Expand Up @@ -1074,7 +1077,7 @@ BeaconError AdvertiseBeaconResult::Error() const
// -----------------------------------------------------------------------------

Researcher::Researcher()
: m_mining_id(MiningId::ForInvestor())
: m_mining_id(MiningId::ForNoncruncher())
, m_beacon_error(GRC::BeaconError::NONE)
{
}
Expand Down Expand Up @@ -1150,20 +1153,22 @@ std::string Researcher::Email()
{
std::string email;

// If the investor mode flag is set, it should override the email setting. This is especially important now
// that the read-write settings file is populated, which overrides the settings in the config file.
if (gArgs.GetBoolArg("-investor", false)) return email;
// If the non-cruncher mode flag is set, it should override the email setting. This is especially important now
// that the read-write settings file is populated, which overrides the settings in the config file. The legacy
// -investor argument is also supported for backward compatibility.
if (gArgs.GetBoolArg("-noncruncher", false) || gArgs.GetBoolArg("-investor", false)) return email;

email = gArgs.GetArg("-email", "");
email = ToLower(email);

return email;
}

bool Researcher::ConfiguredForInvestorMode(bool log)
bool Researcher::ConfiguredForNoncruncherMode(bool log)
{
if (gArgs.GetBoolArg("-investor", false) || Researcher::Email() == "investor") {
if (log) LogPrintf("Investor mode configured. Skipping CPID import.");
if (gArgs.GetBoolArg("-noncruncher", false) || Researcher::Email() == "noncruncher"
|| gArgs.GetBoolArg("-investor", false) || Researcher::Email() == "investor") {
if (log) LogPrintf("Non-cruncher mode configured. Skipping CPID import.");
return true;
}

Expand All @@ -1182,16 +1187,16 @@ void Researcher::MarkDirty()

void Researcher::Reload()
{
if (ConfiguredForInvestorMode(true)) {
StoreResearcher(Researcher()); // Investor
if (ConfiguredForNoncruncherMode(true)) {
StoreResearcher(Researcher()); // Non-cruncher
return;
}

// Don't force an empty email to investor mode for pool detection:
// Don't force an empty email to non-cruncher mode for pool detection:
if (Researcher::Email().empty()) {
LogPrintf(
"WARNING: Please set 'email=<your BOINC account email>' in "
"gridcoinresearch.conf or 'investor=1' to decline research "
"gridcoinresearch.conf or 'noncruncher=1' to decline research "
"rewards");
}

Expand Down Expand Up @@ -1220,7 +1225,7 @@ void Researcher::Reload(MiningProjectMap projects, GRC::BeaconError beacon_error

projects.ApplyTeamWhitelist(team_whitelist);

MiningId mining_id = MiningId::ForInvestor();
MiningId mining_id = MiningId::ForNoncruncher();

// Enable a user to override CPIDs detected from BOINC's client_state.xml
// file. This provides some flexibility for a user that needs to manage a
Expand All @@ -1234,7 +1239,7 @@ void Researcher::Reload(MiningProjectMap projects, GRC::BeaconError beacon_error
LogPrintf("Configuration forces CPID: %s", mining_id.ToString());
} else {
LogPrintf("ERROR: invalid CPID in -forcecpid");
mining_id = MiningId::ForInvestor();
mining_id = MiningId::ForNoncruncher();
}
}

Expand Down Expand Up @@ -1306,9 +1311,9 @@ bool Researcher::Eligible() const
return false;
}

bool Researcher::IsInvestor() const
bool Researcher::IsNoncruncher() const
{
return m_mining_id.Which() == MiningId::Kind::INVESTOR;
return m_mining_id.Which() == MiningId::Kind::NONCRUNCHER;
}

GRC::Magnitude Researcher::Magnitude() const
Expand Down Expand Up @@ -1387,7 +1392,7 @@ ResearcherStatus Researcher::Status() const
return ResearcherStatus::NO_PROJECTS;
}

return ResearcherStatus::INVESTOR;
return ResearcherStatus::NONCRUNCHER;
}

std::optional<Beacon> Researcher::TryBeacon() const
Expand Down Expand Up @@ -1442,7 +1447,7 @@ bool Researcher::ChangeMode(const ResearcherMode mode, std::string email)
{
email = ToLower(email);

if (mode == ResearcherMode::INVESTOR && ConfiguredForInvestorMode()) {
if (mode == ResearcherMode::NONCRUNCHER && ConfiguredForNoncruncherMode()) {
return true;
} else if (mode == ResearcherMode::SOLO && email == Email()) {
return true;
Expand All @@ -1453,7 +1458,7 @@ bool Researcher::ChangeMode(const ResearcherMode mode, std::string email)
}

gArgs.ForceSetArg("-email", email);
gArgs.ForceSetArg("-investor", mode == ResearcherMode::INVESTOR ? "1" : "0");
gArgs.ForceSetArg("-noncruncher", mode == ResearcherMode::NONCRUNCHER ? "1" : "0");

Reload();

Expand Down
Loading
Loading