diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9e1a6fd2ff..1ce8750694 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -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 \n" + "\n" + " 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> active_beacon_ptrs; + int64_t now = GetAdjustedTime(); + // Minimize the lock on cs_main. { LOCK(cs_main); @@ -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); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 29ed106063..7802386269 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -166,6 +166,7 @@ static const CRPCConvertParam vRPCConvertParams[] = // Mining { "advertisebeacon" , 0 }, + { "beaconreport" , 0 }, { "superblocks" , 0 }, { "superblocks" , 1 },