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 Dec 16, 2024
1 parent 2220b1d commit f8b563c
Show file tree
Hide file tree
Showing 2 changed files with 13 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
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "getblockstats" , 2 },
{ "inspectaccrualsnapshot" , 0 },
{ "listmanifests" , 0 },
{ "listprojects" , 0 },
{ "sendalert" , 2 },
{ "sendalert" , 3 },
{ "sendalert" , 4 },
Expand Down

0 comments on commit f8b563c

Please sign in to comment.