Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,28 @@ UniValue revokebeacon(const UniValue& params, bool fHelp)

UniValue beaconreport(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 0)
if (fHelp || params.size() > 1)
throw runtime_error(
"beaconreport\n"
"beaconreport <active only>\n"
"\n"
"<active only> Boolean specifying whether only active beacons should be \n"
" returned. Defaults to false which also includes expired beacons."
"\n"
"Displays list of valid beacons in the network\n");

bool active_only = false;

if (params.size() == 1)
{
active_only = params[0].getBool();
}

UniValue results(UniValue::VARR);

std::vector<std::pair<GRC::Cpid, GRC::Beacon_ptr>> active_beacon_ptrs;

int64_t now = GetAdjustedTime();

// Minimize the lock on cs_main.
{
LOCK(cs_main);
Expand All @@ -761,6 +773,8 @@ UniValue beaconreport(const UniValue& params, bool fHelp)
{
UniValue entry(UniValue::VOBJ);

if (active_only && beacon_pair.second->Expired(now)) continue;

entry.pushKV("cpid", beacon_pair.first.ToString());
entry.pushKV("address", beacon_pair.second->GetAddress().ToString());
entry.pushKV("timestamp", beacon_pair.second->m_timestamp);
Expand Down
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ static const CRPCConvertParam vRPCConvertParams[] =

// Mining
{ "advertisebeacon" , 0 },
{ "beaconreport" , 0 },
{ "superblocks" , 0 },
{ "superblocks" , 1 },

Expand Down