From 6dbd14526e9172a859ace22426fc8317e0e86941 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sun, 24 Nov 2024 19:38:46 -0500 Subject: [PATCH] Extend listprojects This adds a boolean argument to the listprojects RPC function. This boolean defaults to false, which only lists active projects. When true, it will list projects of every status. --- src/rpc/blockchain.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1e8682d160..e88022d219 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2592,15 +2592,23 @@ UniValue debug(const UniValue& params, bool fHelp) UniValue listprojects(const UniValue& params, bool fHelp) { - if (fHelp || params.size() != 0) + if (fHelp || params.size() > 1) throw runtime_error( - "listprojects\n" + "listprojects \n" + "\n" + " -> true to show all projects, including greylisted and deleted. Defaults to false.\n" "\n" "Displays information about whitelisted projects.\n"); UniValue res(UniValue::VOBJ); - for (const auto& project : GRC::GetWhitelist().Snapshot().Sorted()) { + GRC::Project::ProjectFilterFlag filter = GRC::Project::ProjectFilterFlag::ACTIVE; + + if (params.size() && params[0].get_bool() == true) { + filter = GRC::Project::ProjectFilterFlag::ALL; + } + + for (const auto& project : GRC::GetWhitelist().Snapshot(filter).Sorted()) { UniValue entry(UniValue::VOBJ); entry.pushKV("version", (int)project.m_version); @@ -2615,6 +2623,7 @@ UniValue listprojects(const UniValue& params, bool fHelp) } entry.pushKV("time", DateTimeStrFormat(project.m_timestamp)); + entry.pushKV("status", project.StatusToString()); res.pushKV(project.m_name, entry); }