Skip to content

Commit 6dbd145

Browse files
committed
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.
1 parent 9df80a3 commit 6dbd145

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Diff for: src/rpc/blockchain.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -2592,15 +2592,23 @@ UniValue debug(const UniValue& params, bool fHelp)
25922592

25932593
UniValue listprojects(const UniValue& params, bool fHelp)
25942594
{
2595-
if (fHelp || params.size() != 0)
2595+
if (fHelp || params.size() > 1)
25962596
throw runtime_error(
2597-
"listprojects\n"
2597+
"listprojects <bool>\n"
2598+
"\n"
2599+
"<bool> -> true to show all projects, including greylisted and deleted. Defaults to false.\n"
25982600
"\n"
25992601
"Displays information about whitelisted projects.\n");
26002602

26012603
UniValue res(UniValue::VOBJ);
26022604

2603-
for (const auto& project : GRC::GetWhitelist().Snapshot().Sorted()) {
2605+
GRC::Project::ProjectFilterFlag filter = GRC::Project::ProjectFilterFlag::ACTIVE;
2606+
2607+
if (params.size() && params[0].get_bool() == true) {
2608+
filter = GRC::Project::ProjectFilterFlag::ALL;
2609+
}
2610+
2611+
for (const auto& project : GRC::GetWhitelist().Snapshot(filter).Sorted()) {
26042612
UniValue entry(UniValue::VOBJ);
26052613

26062614
entry.pushKV("version", (int)project.m_version);
@@ -2615,6 +2623,7 @@ UniValue listprojects(const UniValue& params, bool fHelp)
26152623
}
26162624

26172625
entry.pushKV("time", DateTimeStrFormat(project.m_timestamp));
2626+
entry.pushKV("status", project.StatusToString());
26182627

26192628
res.pushKV(project.m_name, entry);
26202629
}

0 commit comments

Comments
 (0)