From 4449b1ded720dde206b2909eb4103ff7a4f9db7c Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sat, 18 Nov 2023 21:45:14 -0500 Subject: [PATCH] Implement greylist state for projects in GUI projects table This commit introduces a greylist state for whitelisted entries. Currently this state corresponds to projects on the whitelist that are excluded from the scraper convergence and therefore superblock. --- src/qt/researcher/projecttablemodel.cpp | 6 ++++- src/qt/researcher/researchermodel.cpp | 30 ++++++++++++++++++++++--- src/qt/researcher/researchermodel.h | 9 +++++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/qt/researcher/projecttablemodel.cpp b/src/qt/researcher/projecttablemodel.cpp index 9170e09a34..e24247a8d3 100644 --- a/src/qt/researcher/projecttablemodel.cpp +++ b/src/qt/researcher/projecttablemodel.cpp @@ -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: diff --git a/src/qt/researcher/researchermodel.cpp b/src/qt/researcher/researchermodel.cpp index a6062c50ba..d19a57b320 100644 --- a/src/qt/researcher/researchermodel.cpp +++ b/src/qt/researcher/researchermodel.cpp @@ -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" @@ -23,6 +24,7 @@ #include extern CWallet* pwalletMain; +extern ConvergedScraperStats ConvergedScraperStatsCache; using namespace GRC; using LogFlags = BCLog::LogFlags; @@ -481,6 +483,13 @@ std::vector ResearcherModel::buildProjectTable(bool extended) const // const WhitelistSnapshot whitelist = GetWhitelist().Snapshot(); + std::vector 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 @@ -516,7 +525,14 @@ std::vector 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) { @@ -531,7 +547,7 @@ std::vector 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; @@ -552,7 +568,7 @@ std::vector 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; @@ -564,6 +580,14 @@ std::vector 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; diff --git a/src/qt/researcher/researchermodel.h b/src/qt/researcher/researchermodel.h index 8d6b6df341..125de50fe9 100644 --- a/src/qt/researcher/researchermodel.h +++ b/src/qt/researcher/researchermodel.h @@ -59,7 +59,14 @@ enum class BeaconStatus class ProjectRow { public: - bool m_whitelisted; + enum WhiteListStatus + { + False, + Greylisted, + True + }; + + WhiteListStatus m_whitelisted; std::optional m_gdpr_controls; QString m_name; QString m_cpid;