Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui, projects: Implement greylist state for projects in GUI projects table #2715

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
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