Skip to content

Commit

Permalink
Extend listprojects
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamescowens committed Nov 25, 2024
1 parent 9df80a3 commit 6dbd145
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bool>\n"
"\n"
"<bool> -> 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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 6dbd145

Please sign in to comment.