Skip to content

Commit

Permalink
Merge pull request gridcoin-community#2715 from jamescowens/implement…
Browse files Browse the repository at this point in the history
…_greylist_display

gui, projects: Implement greylist state for projects in GUI projects table
  • Loading branch information
jamescowens authored Nov 20, 2023
2 parents a342433 + 4449b1d commit 9f5ab15
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/qt/researcher/projecttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ QVariant ProjectTableModel::data(const QModelIndex &index, int role) const
}
break;
case Whitelisted:
if (row->m_whitelisted) {
if (row->m_whitelisted == ProjectRow::WhiteListStatus::True) {
return QIcon(":/icons/round_green_check");
} else if (row->m_whitelisted == ProjectRow::WhiteListStatus::Greylisted) {
return QIcon(":/icons/warning");
} else if (row->m_whitelisted == ProjectRow::WhiteListStatus::False) {
return QIcon(":/icons/white_and_red_x");
}
break;
case GDPRControls:
Expand Down
30 changes: 27 additions & 3 deletions src/qt/researcher/researchermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "gridcoin/quorum.h"
#include "gridcoin/researcher.h"
#include "gridcoin/scraper/scraper.h"
#include "gridcoin/superblock.h"
#include "node/ui_interface.h"

#include "qt/bitcoinunits.h"
Expand All @@ -23,6 +24,7 @@
#include <QTimer>

extern CWallet* pwalletMain;
extern ConvergedScraperStats ConvergedScraperStatsCache;

using namespace GRC;
using LogFlags = BCLog::LogFlags;
Expand Down Expand Up @@ -481,6 +483,13 @@ std::vector<ProjectRow> ResearcherModel::buildProjectTable(bool extended) const
//

const WhitelistSnapshot whitelist = GetWhitelist().Snapshot();
std::vector<std::string> excluded_projects;

{
LOCK(cs_ConvergedScraperStatsCache);

excluded_projects = ConvergedScraperStatsCache.Convergence.vExcludedProjects;
}

// This is temporary implementation of the suppression of "not attached" for projects that
// are whitelisted that require an external adapter, and so will not be attached as a native
Expand Down Expand Up @@ -516,7 +525,14 @@ std::vector<ProjectRow> ResearcherModel::buildProjectTable(bool extended) const
// between local projects and whitelisted projects:
//
if (const ProjectEntry* whitelist_project = project.TryWhitelist(whitelist)) {
row.m_whitelisted = true;
if (std::find(excluded_projects.begin(), excluded_projects.end(), whitelist_project->m_name)
!= excluded_projects.end()) {
row.m_whitelisted = ProjectRow::WhiteListStatus::Greylisted;
row.m_error = tr("Greylisted");
} else {
row.m_whitelisted = ProjectRow::WhiteListStatus::True;
}

row.m_name = QString::fromStdString(whitelist_project->DisplayName()).toLower();

for (const auto& explain_mag_project : explain_mag) {
Expand All @@ -531,7 +547,7 @@ std::vector<ProjectRow> ResearcherModel::buildProjectTable(bool extended) const

rows.emplace(whitelist_project->m_name, std::move(row));
} else {
row.m_whitelisted = false;
row.m_whitelisted = ProjectRow::WhiteListStatus::False;
row.m_name = QString::fromStdString(project.m_name).toLower();
row.m_rac = project.m_rac;

Expand All @@ -552,7 +568,7 @@ std::vector<ProjectRow> ResearcherModel::buildProjectTable(bool extended) const

ProjectRow row;
row.m_gdpr_controls = project.HasGDPRControls();
row.m_whitelisted = true;

row.m_name = QString::fromStdString(project.DisplayName()).toLower();
row.m_magnitude = 0.0;

Expand All @@ -564,6 +580,14 @@ std::vector<ProjectRow> ResearcherModel::buildProjectTable(bool extended) const
row.m_error = tr("Uses external adapter");
}

if (std::find(excluded_projects.begin(), excluded_projects.end(), project.m_name)
!= excluded_projects.end()) {
row.m_whitelisted = ProjectRow::WhiteListStatus::Greylisted;
row.m_error = tr("Greylisted");
} else {
row.m_whitelisted = ProjectRow::WhiteListStatus::True;
}

for (const auto& explain_mag_project : explain_mag) {
if (explain_mag_project.m_name == project.m_name) {
row.m_magnitude = explain_mag_project.m_magnitude;
Expand Down
9 changes: 8 additions & 1 deletion src/qt/researcher/researchermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ enum class BeaconStatus
class ProjectRow
{
public:
bool m_whitelisted;
enum WhiteListStatus
{
False,
Greylisted,
True
};

WhiteListStatus m_whitelisted;
std::optional<bool> m_gdpr_controls;
QString m_name;
QString m_cpid;
Expand Down

0 comments on commit 9f5ab15

Please sign in to comment.